Batch rename ?

acidtuch10

Registered
Question on how to do a rename ( .zip to .mp3) in a directory with multiple files? ..... I have done this using a PC .... but now I don't have access to a PC and I am only using my Mac ~ 10.3~ , But am unsure on how to do a batch rename ... Like ... whatever.zip I would like to equal whatever.mp3

Anyhelp would be great

Thanks

Dave
 
I may be out of my league here, but aren't these two different formats entirely? I don't think just renaming would do anything. If you have a hundred zip files that contain mp3's, drag them all to stuffit expander and they will all unzip and create mp3's. If that is what was compressed in the first place.
 
lets say that I renamed them *.zip for what ever reason.....maybe to anybody searching *.mp3 extension. now that they are on a cd and I have to rename whatever.zip to whatever .mp3 to play them ... hense the batch rename ..... So how do i take multipe files named whatever.zip and change every extension to .mp3 instead of .zip?


Thanks
 
Open terminal, find the directory, and type:
mv *.zip *.mp3

If you've never used Terminal, simply open it (from Applications/Utilities), type:
cd
and drag the folder with the files over to the Terminal, the directory will appear in terminal. Hit enter.

then do the above mv command.

HTH
 
Hmm, that doesn't seem to be a supported usage of mv. Doing this under tcsh can have disastrous results, too. You can get the proper results with this (slightly longer) command. First, launch the bash shell in the Terminal so this works right. Just open Terminal, and enter "bash". Then you use cd followed by the full path of the directory containing the files to rename. You can do this step with drag and drop, as Sogni suggested. It should all look something like this:

Code:
bash
cd <directory>
for file in *.zip; do mv $file `echo $file | sed "s/zip/mp3/"`; done

Any file in the current directory with an extension of .zip will now have an extension of .mp3 when you do this.
 
Sogni said:
Wha? Wow you're right... I swear I've done something similar before (on Linux).

I think you might be right, because that looks awfully familiar to me too...
 
For those of us not comfortable using the Terminal, I recommend "A Better Finder Rename" for batch renaming. See versiontracker.com and do a search.

I use it all the time, so I find the price well worth it. What's nice is that you can select a bunch of files and right-click to access the rename utility. Nice.

It supports any sort of renaming processing you could imagine. Extensions, file name start/end of files, sequencing by number/alpha, etc.
 
I'll have to second that "A Better Finder Rename" suggestion -- the trial version only lets you rename ten files or folders at once, but I registered mine and it's been a lifesaver.

Also, I'm not accusing anyone of anything, or implying anything at all, but a lot of MP3s that are downloaded through P2P applications have been renamed with a .zip extension so that they appear to be compressed files and not copyrighted music files.
 
Hi!
I often have to do computer-assisted image analysis. This has to be done blindly, ie the investigator should not know the origin of the images and thus cannot influence (consciously or not) the result of the study. In order to do this, the name of the image is codified (renamed). The original name and the new one are kept in an Excel file until the end of the study. Now comes my question: is there any way to reaffect their original name to the files automatically with a Terminal command that would read the content of the table of conversion ? It is really tedious to do it by hand since I have to convert the names of 300-500 files each time!!!

Thkx for your suggestions
 
I'm sure the terminal rename is doable, but I Have no idea how it would be done since I don't program. I guess that was a completely useless thing to say. Sorry to waste everyone's time.

I have a programmer that does very similar things for our websites, but he uses Perl or similar backend tricks with custom scripts for batch processing. Again, that doesn't help you.

Is there any reason you can't simply keep a duplicate folder of the unchanged images?
 
Thank you Bobw, I will give a look to the 'applescript link'.
Minbed, I am not sure that I was clear enough. It is fine for me to keep a duplicate folder but I have to change all the names of the files in one of the folders...Anyway, thank you for your contribution. I am new in this forum and I got responses to my first post! I really appreciate!!

Regards!
 
Minbed, i finally understood what was the misunderstanding point: in order to make it more clear, I should have written:

"The names of the images are codified during the aquisition. The codified name and the 'real name' are kept in an Excel file until the end of the study. Now comes my question: is there any way to reaffect their real name to the files automatically with a Terminal command that would read the content of the Excel table of conversion ? "

Thus, the files were never saved with their real names. The conversion table is really simple. It looks like:

Code Real Name
1 58
2 33
3 125
4 5
... ...

Thank you again for your help and sorry for the confusion...
 
sure, if you can right out the excel file to some more 'sensible' format, i.e. not proprietary spreadsheet format. I don't know excel, but I assume you could. I'll assume you've got the file to comma separated values (csv), one filename pair per line.

Then:

foreach pair ( `cat filenames.csv`)
set code = `echo $pair | cut -d "," -f 1`
set orig = `echo $pair | cut -d "," -f 2`
mv $code $orig
end
 
I followed the advice of Bobw and went to applescript forum (http://bbs.applescript.net/cgi-bin/webbbs_config.pl). I found there very helpful and competent guys that solved rapidly my problem with a very simple appplescript:


property sourceFolder : "path to the folder" -- adjust as appropriate

-- read in the list of names
set filenameList to read file "path to the text tabulated conversion file" using delimiter {return}

-- in order to break out the two fields we need to play
-- with text item delimiters
set {oldDelims, text item delimiters} to {text item delimiters, tab}

-- we're going to use the Finder to do this
tell application "Finder"
****-- loop through the list
******repeat with aFile in filenameList
**********-- work out the current file name
**********set codified_name to (sourceFolder & ":" & (text item 1 of aFile)) as string
**********-- get the real name of the file
**********set real_name to text item 2 of aFile
**********-- and rename it
**********set name of file codified_name to real_name
******end repeat
end tell

(if you copy/paste, you will have to remove the stars that I have added to show the increments of the script)
It works really fine now and I will save so much time. I think that this trick can be so useful even for other purposes: you only need to make a conversion table with the current names of the files in one column and the new filenames in the second one.

Now, concerning Renamer4Mac, it is a nice application but it could not do the job (ie take the new filename from a conversion table).

Scruffy, I did not yet try your trick but now, I have the feeling that the Applescript solution is so nice that I will postpone my immersion in the Terminal another time.

Thank to all of you for your kind and appreciated help!!
 
There is a Unix tool named "mmv" by Vladimir Lanin, I got it from a news group in 1989, that does multiple renames in the terminal. I compiled it in Jaguar, the same binary works in Panther.

mmv "*.zip" "=1.mp3"

Try Fink or Google to find it.
 
Back
Top