Missing something with Do Shell Script

So, I am getting close to getting this script working but something is still not working.

I have a folder action script (which I’ve revised to work as a standalone script). It is to send a job to the command line version of Compressor. Anyway, work in progress script below:


--on adding folder items to thisFolder after receiving theItems
set theItems to choose file with prompt "Select File"
tell application "Finder"
	set file_name to displayed name of theItems
	
	--repeat with i in theItems
	--	set theName to the name of (item i of theItems)
	--end repeat
	
	
	set compressor_appfile to (application file id "com.apple.compressor.Compressor" as Unicode text)
	set theFiles to the quoted form of the POSIX path of theItems
	
	set myCluster to the quoted form of "-clustername AntonMacBookPro"
	set the compressor_UNIXfile to (compressor_appfile & ":Contents:MacOS:Compressor") as alias
	set the UNIXfile_path to the quoted form of the POSIX path of the compressor_UNIXfile
	
	--
	--repeat with f in theItems
	-- wait for the item to be all there. Since it can take a few minutes for a file to copy over.
	--	set Was to 0
	--	set isNow to 1
	--	repeat while isNow ≠ Was
	--		set Was to size of (info for f)
	--		delay 30 -- longer if getting the item is slow
	--		set isNow to size of (info for f)
	--	end repeat
	--do shell script UNIXfile_path & space & "-clustername AntonMacBookPro\\ Cluster" & space & "-jobpath" & space & theFiles & space & "-settingpath" & space & (quoted form of "/Users/anton/Library/Application\\ Support/Compressor/Apple\\ ProRes\\ 422\\ Interlace.settings") & space & "-destinationpath" & space & (quoted form of "/Users/anton/Movies/") & file_name
	
	do shell script (UNIXfile_path & space & "-clustername" & space & "AntonMacBookPro" & space & "-jobpath" & space & theFiles & space & "-settingpath" & space & (quoted form of "/Users/anton/Library/Application Support/Compressor/Apple ProRes 422 Interlace.settings") & space & "-destinationpath" & space & (quoted form of "/Users/anton/Movies/") & file_name)
	
	
end tell
--end repeat -- get next item f in thisFolder
--end adding folder items to



The resulting Event Log is this:

tell current application
choose file with prompt “Select File”
alias “Macintosh HD:Users:anton:Movies:Converted:C0013.mov”
end tell
tell application “Finder”
get displayed name of alias “Macintosh HD:Users:anton:Movies:Converted:C0013.mov”
“C0013.mov”
get application file id “com.apple.compressor.Compressor”
“Macintosh HD:Applications:Compressor.app”
do shell script “‘/Applications/Compressor.app/Contents/MacOS/Compressor’ -clustername AntonMacBookPro -jobpath ‘/Users/anton/Movies/Converted/C0013.mov’ -settingpath ‘/Users/anton/Library/Application Support/Compressor/Apple ProRes 422 Interlace.settings’ -destinationpath '/Users/anton/Movies/'C0013.mov”
“”
end tell

But the job doesn’t get submitted.

If I would submit the job in terminal, I would do the following command:

cd /Applications/Compressor.app/Contents/MacOS

and then I would have to do:

./Compressor -clustername AntonMacBookPro -jobpath /Volumes/SourceLocation/ClipToCompress.mov -settingpath /Users/TheUsersName/Library/Application\ Support/Compressor/TheSettingYouWant/setting -destinationpath /Users/DestinationFolder/theCompressedFileName.mov

This works every time.

So, what isn’t translating right?

Cheers.

Hi tunaking,

the quotation of the destination path isn’t correct, set the parentheses this way

quoted form of (“/Users/anton/Movies/” & file_name)

Note: two user independent relative paths
path to movies folder as Unicode text – the string path to the Movies Folder of the current user
((path to home folder as Unicode text) & “Library:Application Support:”) – the string path to Application Support folder of the current user

Awesome. I will try it.

Got it to work. Thank you. It was, in fact, two things. The Quoted form issue you brought up and a typo. I wrote “settings” instead of “setting”. Maddening.

Great, good to hear.

It’s always a good feeling, when a script finally does, what it should do :wink:

Alas, still one last hang up. And it is endlessly frustrating to troubleshoot a script when it becomes a folder action, becuase it just does nothing…No, event logging…

So, I converted the script that was working as a standalone script well back into a folder action script. And then I attached it to a folder, drop some movies on it and nothing…


on adding folder items to thisFolder after receiving theItems
	tell application "Finder"
		--set theItems to choose file with multiple selections allowed
		--tell application "Finder" to set thisFolder to container of (item 1 of theItems) as alias
		
		--repeat with f in theItems
		repeat with f from 1 to the number of items in theItems
			
			set file_name to name of (info for f)
			
			
			if the file_name does not contain "InProgress-" then
				-- this "InProgress-" bit of code is for XDCAM video...long story...works in standalone version...
				
				set compressor_appfile to (application file id "com.apple.compressor.Compressor" as Unicode text)
				set theFiles to the quoted form of the POSIX path of f
				set myCluster to the ("-clustername" & space & (quoted form of "This Computer"))
				set the compressor_UNIXfile to (compressor_appfile & ":Contents:MacOS:Compressor") as alias
				set the UNIXfile_path to the quoted form of the POSIX path of the compressor_UNIXfile
				
				
				
				-- wait for the item to be all there. Since it can take a few minutes for a file to copy over.
				set Was to 0
				set isNow to 1
				repeat while isNow ≠ Was
					set Was to size of (info for f)
					delay 15 -- longer if getting the item is slow
					set isNow to size of (info for f)
				end repeat
				
				
				do shell script (UNIXfile_path & space & myCluster & space & "-jobpath" & space & theFiles & space & "-settingpath" & space & (quoted form of ("/Users/anton/Library/Application Support/Compressor/Apple ProRes 422 Interlace.setting")) & space & "-destinationpath" & space & (quoted form of ("/Users/anton/Movies/" & file_name)))
				delay 2
			end if
			
		end repeat -- get next item f in thisFolder
	end tell
end adding folder items to



Sigh.