Watch folder for compressor

Hey guys,

First time posting on this forum,

I am trying to get a handle on action script so i can automate a bunch of tasks and automate some processes. One of which is a watch folder that automatically runs and video file added to it through a compressor droplet.

I have found an excellent tutorial with code that nearly does everything i want it to do, and i have gone though it all and think i have a handle on how it is working.

The only thing it doesn’t do is also run a file through the droplet if it is overwritten (which i really need).

Is there any code that as well as running “on adding” to the folder would also run on overwrite or replace.

I found another post similar to this topic on here but it didn’t seem to cover this question

Any help would be amazing

thanks in advance

dodger



on adding folder items to thisFolder after receiving theItems

  repeat with f in theItems

    set Was to 0

    set isNow to 1

    repeat while isNow ≠ Was

      set Was to size of (info for f)

      delay 30

      set isNow to size of (info for f)

  end repeat

  tell application "Finder"

      open theItems using application file "Droplet.app" of folder "Desktop" of folder "YourUserName" of folder "Users" of startup disk

  end tell

  end repeat 

end adding folder items to


Hi, dodger. Welcome to MacScripter.

I’m afraid not. Folder actions are only triggered by things which happen to the folder itself ” ie. opening or closing the folder, adding or removing items. The watch system can be fooled into triggering by changing the names of items in the folder (the system thinks the folder’s contents have changed), but simply updating items won’t trigger a folder action.

Hi dodger,

to get recently changed files in a folder, folderSystem or Volume you may use the find command. In your case “ means the file is actually created in / written to the folder you want to control “ you probably could use the folowing as Stay-Open instead of a FolderAction (Perhaps it should be necessary to combine them, but then it’ll become difficult because you would have to write and compare lists of files to trigger only one action …)
The Script will give a string as output including each file as posix path in a paragraph

Have a nice weekend :slight_smile:

Hans

property myFolder : "ExampleFolder:" --Macpath
property delayCheck : 60

on idle
	
	
	set myFolder to POSIX path of myFolder
	set ChangedFiles to do shell script "find " & (quoted form of myFolder) & space & " \\! -name '.DS_*' -type f -newerct '1 minute ago'" --keine Systemdateien die mit ".DS_" beginnen; nur Dateien, the files whose inode change time is more recent than the current time minus one minute  
	
	if ChangedFiles is not "" then
		--Your Part “ Happy Scripting :)
	end if
	
	return delayCheck
end idle

Hey guys thanks for the tips,

I have thought of a work around that may suit my purposes

What i am trying is to copy a file into my watch folder, the applescript then passes the file onto the comprsessor droplet and then deletes the source file (which is totally fine with me).

The problem is that compressor doesn’t like to overwrite files without a warning dialogue which i don’t want.

is there anyway to get finder to look into the destination folder before setting off the compression ann delete the file it will overwrite before doing the conversion.

my current script is posted

on adding folder items to thisFolder after receiving theItems
	
	-- this is the standard intro for a folder action
	
	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
			
			-- the basic idea is that the script loops until the file size is the same for more than 30 seconds. That means the file has finished copying.
			
			set Was to size of (info for f)
			
			-- this section is getting the file size of the video
			
			delay 10
			
			set isNow to size of (info for f)
			
			-- this section is sampling the file size 30 seconds later
			
		end repeat
		
		tell application "Finder"
			
			delete theItems in folder "target" of folder "Desktop" of folder "Russel" of folder "Users" of startup disk
			
		end tell
		
		
		
		tell application "Finder"
			
			
			
			open theItems using application file "Droplet.app" of folder "Desktop" of folder "Russell" of folder "Users" of startup disk
			
			delay 10
			
			delete theItems
			
		end tell