Need help on droplet

I have just started out on AppleScript. I am trying to write a Droplet where I can drop a bunch of files to be converted to jpgs. The script below works fine when I drop a bunch of files but doesn’t work when I run it as a regular app by double-clicking it. Can anyone help? Thanks.


on run
	choose file with prompt "Select files to convert to jpgs:" with multiple selections allowed
	open {result}
end run

on open the_Droppings
	set destination_folder to choose folder with prompt "Where do you want to save the jpgs?" as string
	
	try
		repeat with a_file in the_Droppings
			set file_path to a_file as string
			with timeout of 900 seconds
				tell application "Image Events"
					launch
					set the_image to open file file_path
					save the_image as JPEG in destination_folder with icon
					close the_image
				end tell
			end timeout
		end repeat
	on error error_msg
		display dialog error_msg
	end try
	tell application "Finder"
		open folder destination_folder
	end tell
	
end open

The open handler is expecting a list. When you use multiple selections allowed a list is returned. Your call to the open handler is that list from choose file and putting it inside another list, which is causing it to fail.

If you use multiple selections, just pass the results:

on run
	choose file with prompt "Select files to convert to jpgs:" with multiple selections allowed
	open result
end run

If you only want to allow selecting one file when using choose file, then you need to put that resulting alias into a list:

on run
	choose file with prompt "Select files to convert to jpgs:"
	open {result}
end run

Edit: Stefan, the open handler can be called directly.

Edit: See also: Open Handlers

Thanks, I’ve removed my response ashamed :confused: