LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Solution: renaming multiple files with spaces (https://www.linuxquestions.org/questions/linux-newbie-8/solution-renaming-multiple-files-with-spaces-162655/)

HawkeyeCoug 03-26-2004 10:57 AM

Solution: renaming multiple files with spaces
 
I have been struggling to figure out how to rename multiple music files. I usually like to name my music files in a "artist~CD~track~title" or "CD~track~artist~title" format. However, sometimes I don't like the way the naming came out, and want to change the artist or CD name. I know I can do it by using the mouse and renaming that way, but it gets tiring, especially when I know there is some way to do it from the command line.

Part of my problem with the command line was dealing with the spaces in my files. I prefer to have spaces because it really does make it much easier to read, as opposed to using the underscore. Anyway, I kept running into problems using the "mv" command to try and rename them. Finally, I lighted upon the rename command, and after a few more trials and errors, got it to work. Here is the command I gave it. Hopefully it will save you some time.

First, I wanted to insert a "Volume 1" designation into the title of a CD that didn't have one.

So, I gave the command: rename "The Best of Tchaikovsky" "The Best of Tchaikovsky V1" The*

The quotes keep the file name together. This then replaces each instance of "The Best of Tchaikovsky" with the same thing plus a V1. No wildcards necessary, as it finds the matches automatically. In fact, it messes it up if you stick a wildcard on the end. The final argument, The*, chooses every file in the directory starting with "The" to make the change to.

I hope this helps you keep your music or other types of files with long names and spaces in line. I think the rename works much better than mv for these, as I havn't got mv to work like this. Although I am sure that someone with more knowledge than me knows many ways of doing this.


All times are GMT -5. The time now is 08:16 AM.