Apple Compressor -- Folder action to activate droplet

I am trying to use Apple Compressor to automate video compression across a network. Compressor easily creates droplet applications to automate the compression process, but I would like to make a script to automatically “drag” a file into the droplet when it is copied over the network into a particular folder on the server.

Is this possible with applescript? Might there be a better way to do this?

Any help would be greatly appreciated.

Thanks!

You can try this syntax:

tell application "Finder" to open alias "file:to:process" using application file "path:to:compressor droplet"

If it works for you, you can simply attach a folder action to the related folder…

Thanks for the help… I was able to get the expression to work with an absolute file path, but how do I make it so the “file:to:process” path becomes whatever gets dropped into a folder using an action?

I tried the following:

on adding folder items to this_folder after receiving added_items
tell application “Finder”
open alias of added_items using application file “NAME_OF_DROPLET”
end tell
end adding folder items to

What am I doing wrong?

Thanks!

Does this work?

on adding folder items to this_folder after receiving added_items
	tell application "Finder"
		open added_items using application file "NAME_OF_DROPLET"
	end tell
end adding folder items to

– Rob

I tried this change and I still can’t get anything to happen. I tested other folder action scripts on my system, and everything worked OK… So the problem is somehow in this syntax.

I’m pretty new using applescript, but I think the problem is somehow related to the name of the file not being translated properly… I tried the following change to see if I could get the computer to pop up the name of the file, but still no luck:

on adding folder items to thisFolder after receiving addedItems
repeat with anItem in addedItems
display dialog anItem
end repeat
end adding folder items to

Once again, any help would be great.

Thanks

I tested the script before suggesting it and it worked. I just did another test with the same results. In your script, where it says “NAME_OF_DROPLET”, it should be “path:to:droplet”. Maybe this is the problem.

– Rob

Rob – Thanks for your help…

It turns out that Apple’s Compressor program is a bit buggy and that is what was causing the problem. Since the program isn’t scriptable, I was trying to automate dragging a file onto a droplet. For some reason, when this is done through applescript, the file becomes attached but will not submit into the system to be compressed.

Rather than spend more time, I have decided to go back and use Discreet’s Cleaner 6 software to compress my videos. It has scripting built in and the applescript knowledge I gained from doing this project will help me get started with Cleaner.

I have a question for you, however… In another post you mentioned that you had created a script to check the size of a file until it is stable, and then move on. The script I’m writing is so large (over 1GB) files can be copied over a network to the compression machine. How can I get applescript to wait until the whole file is there before trying to encode?

Thanks again!

Craig

Once the file starts downloading/transferring, pass its path to this repeat loop. You might want to adjust/increase the sleep time if all of the files are large. The 10 second sleep will still work but the script doesn’t really need to check a 1 GB file every 10 seconds unless you have an extremely fast connection.

repeat
	set size1 to size of (info for alias "path:to:file")
	do shell script "sleep 10" -- seconds
	set size2 to size of (info for alias "path:to:file")
	if size1 is equal to size2 then exit repeat
end repeat

– Rob

I was working on the same kind of sollution, and am sorry to hear that it doesn´t work.
Is there anyone who knows if there is a sollution to the problem with Compressor droplets?

Actually, there is a solution to this! If you open the droplet, there is a checkbox that says “Show at Launch”, if you uncheck that the droplet will emediatly proces the file.

This works pretty well.


on adding folder items to thisFolder after receiving theItems
	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
		tell application "Finder"
			open theItems using application file "iPodVideo.app" of folder "Desktop" of folder "anton" of folder "Users" of startup disk
		end tell
	end repeat -- get next item f in thisFolder
end adding folder items to


HI Guys,
I have been using the same type of script and my droplet just opens and hangs. The first time or two, it works and then after that, the droplet opens and then it stays open and does not process the request. Has anyone run across this?


on adding folder items to thisFolder after receiving theItems
	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 5 -- longer if getting the item is slow
			set isNow to size of (info for f)
		end repeat
		
		--put in a try statement to see if the file is an mov file
		
		tell application "Finder"
			set folderName to alias "Server HD:Users:playout2:Desktop:CompressorQ:"
			open theItems using application file "16x9 Web 600 Kbs.app" of folderName
		end tell
		
		delay 30
		do shell script ("rm \"" & POSIX path of f & "\"")
	end repeat -- get next item f in thisFolder
end adding folder items to




You may want to also check that the dropped file is > 0.

Some programs create a new output file with a size of 0 bytes, and then wait until they’ve finished processing to write any data into it. Therefore, if you check the file size twice, it won’t change within the 5 or 10 seconds that the script delays, so the script will believe that the file is complete and try and run with it.