Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Linux Mint 14 (Cinnamon), Xubuntu 12.04, Ubuntu 10.04
Posts: 49
Rep:
Rename problems....
Searched many of the threads here trying to figure out how to use rename function, also checked the man and info pages, to no avail.
I've got a folder with plenty of mp3 tracks. The problem is many of them have multiple spaces in the name and the extension is in CAPS. So I thought I'd start little by replacing all extensions to lower case.
Following the rename example from the man pages, I tried this, but it didn't work
Code:
rename .MP3 .mp3 *.MP3
Searching a little the web, I've encountered the following format, which didn't work either
Code:
rename 's/\.MP3/\.mp3/g' *.MP3
I've checked my syntax using sed which echoed the right results, but of course, did not rename the files
The problem: there are two seperate rename commands, one from perl, another more basic. The first example is the more basic rename command from util-linux i think, the second is for the perl version. So, the first question, what rename command do you have installed (as they are not compatible)?
Also, what do you mean by it dident work? Any error messages to show? And i assume are you already in the same directory as the files you want renamed.
Distribution: Linux Mint 14 (Cinnamon), Xubuntu 12.04, Ubuntu 10.04
Posts: 49
Original Poster
Rep:
Using rename from util-linux-2.12r, so I guess we're dealing with the basic one.
Didn't work == no error msgs, just acting as if it has worked but no file changes made. Of course I'm in the directory and have permission to rename files there.
I've tried the more complex bash script
Code:
for OLD_FILE in *.MP3
do
NEW_FILE=$(echo $OLD_FILE | tr '[:upper:]' '[:lower:]' | tr '[ ]+' '.')
mv $OLD_FILE $NEW_FILE
done
Which throws errors for each file saying that $NEW_FILE is not a directory (???)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.