renaming files - problem 7.18 out of applescripting 1-2-3

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:
2-hs-2006-23-a-print 2
3-hs-2006-23-a-print 2
5-hs-2004-19-d-full_jpg 2

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.

Hi, macbrock.

Should be ‘item i’ in the fourth line:

set thisItem to item i of theseItems

The script works apart from that, if I’ve understood what you want it to do.

I appreciate the help! i must have messed with that for an hour last night and was automatically interpreting the error as the way the file names were made. Thanks for the catch. Works like a charm.