I'm trying to organize my CD collection that I've burned to my server, mostly because it works better on my media player if the filenames follow a certain structure. Unfortunately, I'd burned these over several years using different tools and my file naming convention fell lax. Plus I bought sime music on-line in digital format so it's named the way the service names them, and they're not all the same.
Here's what I have:
2000+ files distributed among a few hundred directories (artist/album)
They are mostly mp3 or flac
They mostly are named "01 Songtitle" or "01 - Songtitle" plus their file type, however some are named "1 - Songtitle" or "1 Songtitle"
In these folders are also other types of files like cover art and m3u playlists which I want to ignore (not rename)
What I'd like to accomplish is renaming them all to to "01 - Songtitle".
I'm assuming I have two tasks:
If the filename starts with "number/space" then insert a leading zero, then;
If the filename starts "number/number/space/letter" then insert "space/dash" after the second number.
I've been doing this manually, but it's quite tedious so I'm looking to boost the time to finish this task. I'm assuming I can do this with either sed or find but I haven't figured out the magic sauce yet.
Any "Masters of Bash" out there willing to point me in the right direction?
I'm willing to accept a few hiccups like an album that starts with a number - I can manually find those and temporarily move them out of the way. I suppose if I use find I can just act on filenames which might solve that.
Here's what I have:
2000+ files distributed among a few hundred directories (artist/album)
They are mostly mp3 or flac
They mostly are named "01 Songtitle" or "01 - Songtitle" plus their file type, however some are named "1 - Songtitle" or "1 Songtitle"
In these folders are also other types of files like cover art and m3u playlists which I want to ignore (not rename)
What I'd like to accomplish is renaming them all to to "01 - Songtitle".
I'm assuming I have two tasks:
If the filename starts with "number/space" then insert a leading zero, then;
If the filename starts "number/number/space/letter" then insert "space/dash" after the second number.
I've been doing this manually, but it's quite tedious so I'm looking to boost the time to finish this task. I'm assuming I can do this with either sed or find but I haven't figured out the magic sauce yet.
Any "Masters of Bash" out there willing to point me in the right direction?
I'm willing to accept a few hiccups like an album that starts with a number - I can manually find those and temporarily move them out of the way. I suppose if I use find I can just act on filenames which might solve that.
Comment