Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

remove prefix numbers from filename

There are like 500 photos which have numbers prefixed before their name. They are all in iphoto 09. The Batch change options doesn't allow text to be replaced. The automator action for renaming finder items does allow replace however one has to specify what to replace, which in my case would be random numbers from 1 to 900. Is there any way I can prefix this images from 1 to 500 by first replacing the first three characters from the images, which in our case are all different numbers?

Neerav

MacBook5,1, Mac OS X (10.6.1)

Posted on Oct 5, 2009 9:20 AM

Reply
6 replies

Nov 27, 2009 10:49 AM in response to AceNeerav

Hi Neerav,
Maybe you can try doing this with an applescript. After you get/select the files somehow in Automator, add the *Run Applescript* action after that. Add this piece of code after the *on run {input, parameters}* line:
repeat with thisFile in input
tell application "Finder"
set fileName to name of (thisFile as alias)
set fileName to (do shell script "echo " & quoted form of fileName & " | sed 's/^[0-9]*//'")
set name of thisFile to fileName
end tell
end repeat

This will delete any numbers that appear in the beginning of the file name. This approach is better than deleting the first three characters in case the numbers aren't padded with leading zeroes.
Anyway, I haven't tested this script myself so back up some files and run it on a such a small sample so that if there are any bugs (I don't expect any) we can remove them.

Message was edited by: hungryjoe

remove prefix numbers from filename

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.