Removing text from name of file

I have a series of files that are basically named “My File - Feb 27 2004 Part 1.doc” that I download on a regular basis. The prefix "My File - " always remains the same. The date is the thing that (duh :slight_smile: constantly changes.

I would like to be able to remove the text "My File - " from every file that I process using either a folder action or droplet.

How can I do that?

TIA!

Save this as an application (droplet) and it might work. Note that it will work only on dropped files. Let us know if you need to process folders.

on open items_
	repeat with item_ in items_
		tell application "Finder"
			if kind of item_ is not "Folder" then
				set name_ to name of item_
				if name_ begins with "My File - " then
					try
						set name of item_ to (text 11 thru end of name_)
					on error e
						display dialog e buttons {"OK"} default button 1 with icon 0
					end try
				end if
			end if
		end tell
	end repeat
end open

– Rob

Thanks Rob.

Unfortunately I can’t save the script as a droplet - don’t know why. I’m using script editor 2.0 and Panther 10.3.2.

I was able to edit it slightly and make a folder action out of it that works like a charm. :slight_smile:

Thanks again!