Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

IvanKeRi

macrumors newbie
Original poster
Apr 10, 2009
3
0
Cali, Colombia
Dear fellow Applephiles, I'm looking for a fast, efficient way (via an Automator Workflow for example) to do the following:

Rename sequentially several files in certain folders so that their names end up being: "folder_name xx"

e.g. I have 2 folders called Anne's Birthday, Berlin Vacation, and 2008 Prom with several JPEGs called "DSCxxxxxx" within them.

I want the files within each folder to be named:
"Anne's Birthday 1", "Anne's Birthday 2", "Anne's Birthday 3", etc. instead of "DSCxxxxxx",
"Berlin Vacation 1", "Berlin Vacation 2", "Berlin Vacation 3", etc. and "2008 Prom 1", "2008 Prom 2", "2008 Prom 3", etc.
and thus for each respective folder. By using a workflow.​

I truly hope it's just my being slow with Automator (or Mac OS X in general) the obstacle for accomplishing this. I hope you can help me with this. I would really appreciate it. :)
 
Dear fellow Applephiles, I'm looking for a fast, efficient way (via an Automator Workflow for example) to do the following:

Rename sequentially several files in certain folders so that their names end up being: "folder_name xx"

e.g. I have 2 folders called Anne's Birthday, Berlin Vacation, and 2008 Prom with several JPEGs called "DSCxxxxxx" within them.

I want the files within each folder to be named:
"Anne's Birthday 1", "Anne's Birthday 2", "Anne's Birthday 3", etc. instead of "DSCxxxxxx",
"Berlin Vacation 1", "Berlin Vacation 2", "Berlin Vacation 3", etc. and "2008 Prom 1", "2008 Prom 2", "2008 Prom 3", etc.
and thus for each respective folder. By using a workflow.​

I truly hope it's just my being slow with Automator (or Mac OS X in general) the obstacle for accomplishing this. I hope you can help me with this. I would really appreciate it. :)


Sounds like a job for a shell script to be run in Terminal.

Is every file named "DSCxxxxxx", where each "x" is a digit in [0-9]? Are there always six x's after DSC? Do you want the new numbering to match the order of the numbering in the original names? Do you need the spaces in the new names---would BerlinVacation1 or Berlin_Vacation_1 be OK?

Just trying to better understand the situation.
 
I don't think there's a way to automatically "use the folder name" in automator, but it's a fairly simple workflow. You need "Get Specified Finder Items" and then "Rename Finder Items." There's an option for "Make Sequential" and then there's an option to "Add number to existing name/new name." You'd check "new name" and enter in the name of the folder.

You could also do this in Name Mangler, which I find is a much better file renaming application, but it doesn't automatically get the folder name either.
 
Thanks for your replies,


Sounds like a job for a shell script to be run in Terminal.

Is every file named "DSCxxxxxx", where each "x" is a digit in [0-9]? Are there always six x's after DSC? Do you want the new numbering to match the order of the numbering in the original names? Do you need the spaces in the new names---would BerlinVacation1 or Berlin_Vacation_1 be OK?

Just trying to better understand the situation.

LPZ,

Actually there are always 5 "x" after "DSC" (they're photos taken with my Sony Cybershot) in each file name, and YES; each "x" is a digit in [0-9].

I don't mind if the new numbering mathces the order of the original numbering.

And Yes, it would be very nice if the new file names could include spaces between each word.

Thanks A LOT once more,

If you or anyone have any more ideas to solve this "renaming issue" through Terminal, or any other way. PLEASE Help!
 
Thanks for your replies,




LPZ,

Actually there are always 5 "x" after "DSC" (they're photos taken with my Sony Cybershot) in each file name, and YES; each "x" is a digit in [0-9].

I don't mind if the new numbering mathces the order of the original numbering.

And Yes, it would be very nice if the new file names could include spaces between each word.

Thanks A LOT once more,

If you or anyone have any more ideas to solve this "renaming issue" through Terminal, or any other way. PLEASE Help!


Here's one solution.

1) Make a backup copy of each folder (just in case ;) ).

2) Temporarily move each folder to your Desktop

3) Open the Terminal application (it's in your Utilities folder)

4) At the Terminal prompt, enter

cd

5) Then enter

cd Desktop/Berlin\ Vacation

I'm assuming that one folder on your desktop is named Berlin Vacation. You need to type \ before a space when entering the name in Terminal. A \ is also needed before an apostrophe, so Anne's Birthday would be entered as Anne\'s\ Birthday

6) Enter the following sequence of lines, one at a time, exactly as they appear here. You can cut and paste if you wish.

FOLDER=${PWD##*/}
filelist=`ls DSC*`
INDEX=1
for f in $filelist
do
cp $f "$FOLDER $INDEX.jpg"
let "INDEX+=1"
done

7) At this point you should have two copies of each picture in your Berlin Vacation folder, the original and a copy with the name you wanted.

8) Repeat steps 4)--7) for each folder on your Desktop, changing the name you enter in step 5) accordingly.



NOTE: Spaces in file names are a big pain! And so are apostrophes.
 
Something like this?

HTML:
set rootfolder to choose folder with prompt "What folder?" default location path to "cusr"

tell application "Finder"
	set these_items to get items of rootfolder
	repeat with i from 1 to count of these_items
		set this_item to item i of these_items
		set rootname to name of container of this_item
		set name of this_item to rootname & " " & (i as string) & "." & name extension of this_item
	end repeat
end tell

please test on a copy of your folder
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.