Find And Replace Droplet + Multiple Items

Hello all,

I’ve got a droplet that works on one item at a time. I’d like it to work on multiple items i.e. I’d like to drop as many items as I want onto the droplet, and have it replace the name of all of them. How can I make it work?

TIA
Walt :slight_smile:


on open aFile
	set searchStrings to {"Aunt", "Uncle", "Grandmother"}
	set replaceStrings to {"Pam", "Bill", "Jeanette"}
	tell application "Finder"
		set aFile to aFile as alias
		set fileName to name of aFile as string
		repeat with i from 1 to count of searchStrings
			set AppleScript's text item delimiters to item i of searchStrings
			set newName to every text item of fileName
			set AppleScript's text item delimiters to item i of replaceStrings
			set fileName to newName as string
			set name of aFile to fileName
		end repeat
	end tell
end open

I’ve got it. Never mind.
Here’s the script:


on open
set olddelims to AppleScript's text item delimiters -- save their current state
	tell application "Finder" to set fileList to the selection
	set searchStrings to {"Aunt", "Uncle", "Grandmother"}
	set replaceStrings to {"Pam", "Bill", "Jeanette"}
	repeat with aFile in fileList
		set fileName to name of aFile
		repeat with i from 1 to count of searchStrings
			set AppleScript's text item delimiters to item i of searchStrings
			set newName to every text item of fileName
			set AppleScript's text item delimiters to item i of replaceStrings
			set fileName to newName as string
		end repeat
		set name of aFile to fileName
	end repeat
	set AppleScript's text item delimiters to olddelims--return to old state
end open