Changing File Save Destination on a shell script

I’ve modified apples sample Convert to PDF script to make it a folder action script. The original script would save the PDF to the same location as the original. Now it saves it to the root of the Drive. I can’t figure out how to change the shell script variables save to a specified destination. Any ideas?
Thanks in advance.

on adding folder items to this_folder after receiving these_files
	repeat with ThisFile in these_files
		tell application "Finder" to set theString to name of ThisFile as string
		
		set terminalCommand to ""
		set convertCommand to "/System/Library/Printers/Libraries/./convert "
		set newFileName to theString & ".pdf" as string
		set thisPath to "/In/" & theString as string
		set terminalCommand to convertCommand & "-f " & "\"" & thisPath & "\"" & " -o " & "\"" & newFileName & "\"" & " -j \"application/pdf\""
		
		do shell script terminalCommand
		
		tell application "Finder"
			delete file theString of folder "Panther HD:In:"
		end tell
	end repeat	
end adding folder items to

You can try this:

on adding folder items to thisFolder after receiving theseFiles
	repeat with thisFile in theseFiles
		tell application "Finder" to get name of thisFile as text
		
		do shell script "/System/Library/Printers/Libraries/convert -f " & ¬
			quoted form of ("/In/" & result) & ¬
			" -o " & quoted form of POSIX path of (thisFolder & result & ".pdf") & ¬
			" -j \"application/pdf\"; rm " & quoted form of ("/In/" & result)
	end repeat
end adding folder items to

I’m not certain what “/In/” is supposed to be.

Thanks Bruce. But It still puts the file at the root of the Drive. I’m unaware of what POSIX path is, but I trust it’s something that is needed.

Oh yeah. /In was just my way of setting up the folder to grab from. The “In” folder at the root of the drive.

I looked up POSIX path. I understand what you are doing now. Very nice.
What odd is that the “convert” script does not seem to have a destination value.

I tried the same thing and I get what your trying to do.

Try this it works for me, just change the SearchPath, TargetFolder and DestinationFolder Variables.


set SearchPath to "Mac139HD:In:"
set TargetFolder to "/In/"
set DestinationFolder to "/Out/"

tell application "Finder"
	set theFolder to folder (SearchPath as Unicode text)
	set myList to (files of theFolder)
	repeat with thisFile in myList
		set i to name of thisFile
		set newFileName to (characters 1 thru -5) of i as string
		do shell script "/System/Library/Printers/Libraries/convert -f " & quoted form of (TargetFolder & i) & " -o " & DestinationFolder & newFileName & ".pdf" & " -j \"application/pdf\"; rm " & quoted form of (TargetFolder & i)
	end repeat
end tell