G’day
I’ve got a heap of folders with the same script attached.
I want to automate the adding of a folder action to each folder. I can set the folder action for new folders, but can’t find how to check the enabled of the existing attached script.
Anyone know how please?
Regards
Santa
set p2ftpDownloads to ((path to desktop) & "ftp Downloads") as text
set p2me to path to of me
tell application "Finder" to set p2cofme to container of (path to me) as text
set p2FAS to (path to Folder Action scripts folder) as text
set saveFolderAction to (p2cofme & "ftp Downloader.scpt") as text
try
tell application "Finder"
if exists file ((p2FAS & "ftp Downloader.scpt") as text) then
move file "ftp Downloader.scpt" of folder p2FAS to trash
end if
copy file saveFolderAction to folder p2FAS # 'with replacing' not allowed
end tell
on error errmsg
display dialog errmsg
end try
tell application "Finder"
set TempList to folders of folder p2ftpDownloads as list
end tell
tell application "System Events"
set folder actions enabled to true
repeat with eachFolder in TempList
try
attach action to (eachFolder as alias) using ((p2FAS & "ftp Downloader.scpt") as text)
say name of eachFolder as text
on error errmsg number errNum
if errNum = -48 then -- Folder action already exists, but is it active?
if not (folder action "ftp Downloader.scpt" of eachFolder is enabled) then # doesn't work
--set enabled of eachFolder's folder action (("ftp Downloader.scpt") as text) to true
end if
end if
display dialog errmsg & return & errNum
end try
end repeat
end tell