Saturday 10 November 2018

rename - Renaming Linux files that accidentally have multiple .mp3 extensions


I screwed up and accidentally have a bunch of files with the extension .mp3.mp3.mp3.mp3


How can I change these, recursively—and over multiple directories—to set them to just .mp3?



Answer



There is a fairly simple solution, which is to just cut off everything from the first ".mp3" and then add ".mp3" back on. So:


for file in $(find . -name "*.mp3"); do mv "$file" "${file%%.mp3*}.mp3"; done

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...