File drop over network not triggering folder action

I hacked together a script to automate exporting quicktime files. I’m using it as a folder action script so that I can just dump the files in a folder and let it do it’s work. It seems to work pretty well on the desktop level but fails to run if I drop a file in the folder from another computer. I’m using a PC to put files onto the mac desktop. Is there something I need to so specifically in the applescript to make the script run when a file comes over the network?

I don’t know if it’s related but I used to have a similar problem when I had to manually reinitiate my folder actions after every computer restart. These folders were located on a remote volume. I kind of fixed that issue by scripting Folder Actions (modifying supplied folder actions scripts) to re-initiate my folders when my computer boots up. Just save that following script as an application and put it in your login items.

tell application “System Events” to ¬
set FolderActionNames to name of every folder action

if FolderActionNames is not {} then
set ChosenFolders to every item in FolderActionNames

if class of ChosenFolders is boolean then
	--user chose no folders
	repeat with EachFolder in ChosenFolders
		set FolderActionName to contents of EachFolder
		tell application "System Events" to ¬
			set FAScripts to name of every script of folder action FolderActionName
		set ChosenScripts to FAScripts
		if class of ChosenScripts is boolean then
			--user chose no scripts, skip this folder action
			repeat with EachScript in ChosenScripts
				set ScriptName to contents of EachScript
				tell application "System Events" to ¬
					delete script ScriptName of folder action FolderActionName
			end repeat
			--If we deleted all the scripts, delete the folder action object as well
			if (count of FAScripts) is (count of ChosenScripts) then ¬
				tell application "System Events" to ¬
					delete folder action FolderActionName
		end if
	end repeat
end if

display dialog NoFoldersActionsExist with icon note
end if

set targetfolderlist to {“Macintosh HD:Users:scyr:Desktop:”, “Mountable Volume:Folder1”, “Mountable Volume:Folder2”, “Mountable Volume:Folder3”, “Mountable Volume:Folder4”, “Mountable Volume:Folder5”, “Mountable Volume:Folder6”}
set a to 1
set special_script to “Desktop script.scpt”
repeat (count every item in targetfolderlist) times
set TargetFolder to item a of targetfolderlist
if a > 1 then set special_script to “add - new item alert beep.scpt”
tell application “Finder” to ¬
set FAName to name of alias TargetFolder
tell application “System Events”
if folder action FAName exists then
–Don’t make a new one
make new folder action ¬
at end of folder actions ¬
with properties {path:TargetFolder} – name:FAName,
end if
end tell

tell application "System Events"
	tell folder action FAName
		make new script ¬
			at end of scripts ¬
			with properties {name:special_script}
	end tell
end tell
set a to a + 1

end repeat

tell application “Folder Actions Setup”
delay 5
end tell

Thanks for that code, I’ll see if I can utilize that. My script doesn’t trigger at all when a file comes in from the network. It will register a file dragged on the computer it’s running on, but when another computer initiates the copy, it ignores it. I wonder if it’s a limitation of Folder Actions.

I also have a script that I need triggered on an item drop into a folder. My experience with folder actions has been hit and miss in the past. In this case, the files being copied to the folder are coming over the internet. I have made a sript that runs in the background, and it checks for a change in the folder’s modification date to detect any new file drop.

It goes something like this

set TheContainer to (path to folder) as alias
set TheDate to modification date of TheContainer as string
set DateCheck to modification date of TheContainer as string
if not(TheDate=DateCheck) then
–New item in folder, process it
set TheDate=DateCheck
end if
end repeat

BTW I have checked, if you are copying a large file into the folder over the network, the modification date is only changed when the file copy is finished, so this script doesn’t try to grab a file/folder in mid-copy.