Rename

December 15, 2009

I’m sure that many of you have experienced this before, and if not I have experienced it enough times to warrant a post.  I download an album but all the track names have extra letter either appended to the beginning or the end.  And as the name of this post suggest I would like to rename them all and remove these characters.

Sure I could use the mv command or even open up the GUI file browser and go from there, but I want to get this done with as little work as possible.  The funny thing is that I probably spent more time trying to find this solution than it would have taken if I were to actually do this the long way.

Well here is the command you need: rename.  I suggest that you read the man page for it since at this point I’m not all to sure how it works.  But I can provide you with an example of what you need to type to get the job done (in this case at least).  Suppose that the following sequence is after what you want AwX3 and they are all .mp3 files

rename -n 's/AwX3//' *.mp3

Doing this will tell you which files will be renamed and what they would be renamed to.  After you have made sure that everything is alright, run it again but this time with out the -n.

Hope this helps someone, and if not I know it will help me in the future when I have this problem again.

Advertisements