property FolderName : "ftp Downloads"
# The Folder Action script name
property ScriptName : "ftp Downloader.scpt"
property ActionFlag : true
set path2DesktopftpDownloadsFolder to ((path to desktop) & FolderName) as text
set path2FolderActionsScriptsFolder to (path to Folder Action scripts folder) as text
tell application "Finder" to set TempList to folders of folder path2DesktopftpDownloadsFolder as list
set p2me to path to me
tell application "Finder" to set path2ContainerOfMe to container of (path to me) as text
set saveFolderAction to (path2ContainerOfMe & ScriptName) as text
(*
# Check if old version exists, is so, trash it, then renew.
tell application "Finder"
if exists file saveFolderAction then
if exists file ((path2FolderActionsScriptsFolder & ScriptName) as text) then
move file ScriptName of folder path2FolderActionsScriptsFolder to trash
else
set FoundFlag to true # not installed, so set up to strip references to old ones if they exist
end if
copy file saveFolderAction to folder path2FolderActionsScriptsFolder
end if
end tell
*)
tell application "System Events"
set folder actions enabled to true
# This fails
# enable folder action (path2FolderActionsScriptsFolder & ScriptName)
# This fails
# enable folder action ScriptName
repeat with EachFolder in TempList
try
# This worked under Lion, but not Yosemite, now generates "can't make (alias path) into type specifier"
attach action to (EachFolder as alias) using ((path2FolderActionsScriptsFolder & ScriptName) as text)
# This doesn't work, and generates an error
tell (EachFolder as alias) to enable folder action ScriptName
# This doesn't work, and generates an error
tell (EachFolder as alias) to enable folder action (path2FolderActionsScriptsFolder & ScriptName)
set theCounter to theCounter + 1
on error errmsg
display dialog errmsg
end try
end repeat
end tell