Ok i know what the problem is but can’t figure out how to fix it. I used my own file names to do this and they unfortunately have multiple hyphens in them. The problem before this put the numbers in front of the file names and this problem was supposed to simply remove the numbers.
My file names are:
1-hs-2006-23-a-print
2-hs-2006-23-a-print 2
3-hs-2006-23-a-print 2
4-hs-2006-23-a-print
5-hs-2004-19-d-full_jpg 2
etc…
The script to remove the prefix numbers applied in the previous problem is:
tell application "Finder"
set theseItems to (every document file of the front Finder window)
repeat with i from 1 to count of theseItems
set thisItem to i of theseItems
set thisName to the name of thisItem
set the hypenOffset to (the offset of "-" in thisName) + 1
set the originalName to text from the hypenOffset to -1 of thisName
set the name of thisItem to the originalName
log originalName
end repeat
end tell
I’ve tried to modify the line “set the hypenOffset to (the offset of “-” in thisName) + 1” to start with text “hs”, all text after and so forth. The dictionary in the standard additions is no help with the offset command. How can i get this to work on file names that have multiple hyphens. I got it to work on file names that didn’t have the hypens, but would like to figure this out as it will undoubtedly crop up again.