Bulk changing of file names in a folder - possible?

sgould

Registered
I have a set of folders, one for each European Country. Each folder has 80 files with an identical list of names in them.

I want to combine them in one new folder. But, of course, I get asked to replace the first country's file each time I try to add files as the next country folder has a set of files with the same names.

I need an easy way to (say) add the letter "I" to the front of all the filenames in the Italian folder, "G" in front of the filenames in the German folder etc.

Otherwise I have to select each file in turn and add the letter - that's 45 x 80 times!

I will need to repeat this every month as I receive new info.

Help!
 
There are many file-renaming programs. Check out a few at http://www.macupdate.com/search.php?keywords=rename

I always use AppleScript when I need to do something like this, since it's very flexible. It's worth learning AppleScript just to be able to manipulate files in any way you can imagine.

I wrote this script, which will ask you for a folder, then prepend to the name of every file within it the name of that file's parent folder (followed by " - " as a separator).
Code:
tell application "Finder"
	set the_folder to choose folder
	set the_list to every file of the entire contents of the_folder
	repeat with the_file in the_list
		set the name of the_file to the name of the parent of the_file & " - " & the name of the_file
	end repeat
end tell
So if you have a file called "1.txt" in a folder called "Italy", the name will be changed to "Italy - 1.txt". It will do this to every file, even those in nested folders.

You could probably also rig something up with Automator, since it has much of the power of AppleScript. Automator is much easier to use (or at least, that's the idea). I've never used Automator much myself, since I've been using AppleScript for many years and am very comfortable with it, so I can't guarantee that it's flexible enough.
 
Thanks! :)

I'll have a play.

It's about 30 years since I last did any serious programming - mostly "Basic". About time I found a hobby ready for my retirement...

If you don't hear from me again, I will have scripted all the folders on the Mac instead of just the ones I want ;)
 
Back
Top