save as in Preview

here is my script, it stops at “save front document”. Its says I dont have permission. Any ideas.

set the save_location to "/Users/shawnbrady/Desktop/TL/png/"


tell application "Finder"
	set the_files to files of folder "Macintosh HD:Users:shawnbrady:Desktop:TL:"
end tell



repeat with a_file in the_files
	
	tell application "Preview"
		activate
		open a_file
		delay 1
		try
			save front document in POSIX file save_location
		end try
	end tell
	delay 1
	
end repeat

looks to me like you’re trying to save a document as a folder. You need to have a file name on that path, I think. Not tested, but try this:

YEEEESSSS!!! Employee of the month for you. Now I just have to get the source filename and just add “png” to it. Thanks.

set the save_location to "/Users/shawnbrady/Desktop/TL/png/"


tell application "Finder"
	set the_files to files of folder "Macintosh HD:Users:shawnbrady:Desktop:TL:"
end tell



repeat with a_file in the_files
	tell application "Finder"
		set newFileName to name of a_file
		set newFilePath to save_location & newFileName & ".png"
	end tell
	tell application "Preview"
		activate
		open a_file
		delay 1
		try
			save front document in POSIX file newFilePath
		end try
	end tell
	delay 1
	
end repeat