Watch Folder for Compressor Droplet Problems

Hello,

I’m trying to write a Folder Action Script that will do the following:

  1. Wait for a QuickTime movie to finish copying to the folder before starting the Compressor Droplet (Movies can be sixty minutes in length.

  2. Send the movie to the droplet.

I was able to get the AppleScript to successfully send the video to the droplet, but it only worked for very small video files. Anything that took a minute or more to copy to the folder failed, because the movie wasn’t complete when it was submitted to the droplet.

So, the Applescript needs to know when the file is finished copying.

Also, it needs to know if more than one video was added to the folder.

Anyway, my current script may be close…or it may be a total mess (I have lost sight of it).

Here is what I have now:

on adding folder items to this_folder after receiving added_items
	
	
	
	tell application "Finder"
		
		activate
		
		
		set timeout_value to 7600
		repeat with i from 1 to the count of the added_items
			set this_item to item i of the added_items
			set time_increment to 0
			repeat
				try
					if the time_increment is greater than or equal to the timeout_value then exit repeat
					
					set this_info to the info for the this_item
					set size_A to the size of this_info
					delay 2
					set this_info to the info for the this_item
					set size_B to the size of this_info
					if size_A is equal to size_B and size_B is not 0 then
						exit repeat
						open added_items using application file "iPod640X480new.app" of folder "Desktop" of folder "admin" of folder "Users" of startup disk
					else
						set time_increment to time_increment + 5
						
					end if
					
					
				end try
			end repeat
		end repeat
	end tell
	
end adding folder items to


My favorite version goes like this:


on adding folder items to thisFolder after receiving theItems
	repeat with f in theItems
		-- wait for the item to be all there
		set Was to 0
		set isNow to 1
		repeat while isNow ≠ Was
			set Was to size of (info for f)
			delay 2 -- longer if getting the item is slow
			set isNow to size of (info for f)
		end repeat
		-- Now do stuff to this f in thisFolder
	end repeat -- get next item f in thisFolder
end adding folder items to

That worked beautifully. So much simpler too!

Thanks!

so how do you implement this? i copied this into my script editor and saved it. now how do i apply this? thanks
Mitch

First, Folder Action scripts must be saved in either /Library/Scripts/Folder Action Scripts or ~/Library/Scripts/Folder Action Scripts. You may, of course, save an AppleScript with Folder Action handlers anywhere you like, but they will not be usable as Folder Actions unless they are saved in one of those two locations.

-- This script will open either the "local" or "user" Folder Action script folder in Finder.
display dialog "Which Folder Action scripts folder should I open?" & return & return & "Local means the folder under /Library" & return & ¬
	"User means the folder under ~/Library" with title "Open a Folder Action scripts folder in Finder" buttons {"Cancel", "Local", "User"} cancel button "Cancel" default button "Cancel"
if button returned of result is "Local" then
	local domain
else if button returned of result is "User" then
	user domain
end if
path to Folder Action scripts folder from result
tell application "Finder"
	open result
	activate
end tell

Then, once you have the script saved in a proper location, there are two main methods for activating the Folder Action. You can use the context menus in the Finder to attach the script to a folder. Or you can use the Folder Actions Setup application from the AppleScript folder of the Applications folder of your startup disk (/Applications/AppleScript/Folder Actions Setup). (Follow the links to read Apple’s web pages on how to enable and attach Folder Actions.)

So this worked? Could you please post the combined script that you used for the watch folder? Then I can just replace the name and location of your droplet with mine. I’m not quite sure of the syntax. Thanks!

Nevermind: it’s here: http://macscripter.net/viewtopic.php?id=5523 thank you!!!