I’m trying to write a folder action which will rename files added to a folder, with the intention of using this in conjunction with iPhoto’s Export feature. I’d like to export batches of photos from iPhoto, and have the finder automatically rename them in sequence. Here’s what I’ve got thus far:
on adding folder items to this_folder after receiving these_items
tell application "Finder"
set folderCount to (count of (every item of folder this_folder))
repeat with _item in these_items
set folderCount to folderCount + 1
set baseName to name of folder this_folder
set newNumber to folderCount
set newName to baseName & newNumber
set name of _item to newName & ".jpg"
delay 5
end repeat
end tell
end adding folder items to
This is kind-of working, but because iPhoto exports one photo at a time, I think the script is triggered each time that a photo is exported, thereby changing the value of the variable folderCount. So the result is that some numbers are skipped when the Finder is assigning the names. Also, it seems that the final photo of each Export operation is ignored by this script… In any event the final one or two photos often will not be renamed.
Any help with this would be greatly appreciated.