Make script run with multiple selected files

I managed to cobble together the script below to run on a single file, but I’d like to make it possible to select multiple files in Finder then run the script on all of them.

tell application "Finder"
	set theSelection to selection
	set theFile to (item 1 of theSelection) as text
	
	if exists folder ((path to desktop folder as text) & "Exported PNGs") then
		(* Do nothing *)
	else
		make new folder at (path to the desktop folder as text) with properties {name:"Exported PNGs"}
	end if
	
	open the theFile
	delay 0.3
end tell

tell application "Adobe Photoshop CC 2018"
	try
		activate
		set theDocument to the current document
		set currentName to name of theDocument
		set documentBaseName to (items 1 thru ((length of currentName) - 4) of currentName) as string
		set theFile to "~/Desktop/Exported PNGs/" & documentBaseName & ".png"
		save theDocument in theFile as PNG with options {class:PNG save options} appending lowercase extension with copying
		close theDocument
	end try
end tell

tell application "Finder"
	open (path to desktop folder as text) & "Exported PNGs"
	
	tell Finder window "Exported PNGs"
		set current view to icon view
		set the bounds to {755, 335, (1050 + 755), (765 + 340)}
		set its toolbar visible to true
		set its sidebar width to 190
		set its statusbar visible to true
	end tell
	
	tell icon view options of Finder window "Exported PNGs"
		set arrangement to arranged by name
		set shows icon preview to true
		set icon size to 128
		set shows item info to true
	end tell
	
	activate
end tell

I don’t need anything fancy like automatically grabbing all of a folder’s contents or a dialog window asking for files. Just taking the files selected in Finder and running the script on all of them.

Any help would be appreciated :slight_smile:

…never mind, I managed to sort it out :slight_smile: