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
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?
set temp to folder actions
repeat with eachFolder in temp
set FAScripts to name of every script of eachFolder
if "ftp Downloader.scpt" is in FAScripts then
if enabled of eachFolder is false then
display dialog "The following Folder Action 'ftp Downloader.scpt' is turned OFF for folder " & return & return & (name of eachFolder as text) & return & return & "Do you want to turn it ON?" & return buttons {"Turn ON", "Keep OFF"}
if button returned of the result = "Turn ON" then set enabled of eachFolder to true
end if
end if
end repeat
end if
display dialog errmsg & return & errNum
end try
end repeat
end tell
On 09/10/2012, at 1:12 AM, koenig.yvan <
email@hidden> wrote:
Le 08/10/2012 à 15:44, Brian Christmas <
email@hidden> a écrit :
Apple deliver with the operationg systems some scripts whose contents may help :
Macintosh HD:Library:Scripts:Folder Actions:Remove Folder Actions.scpt
Macintosh HD:Library:Scripts:Folder Actions:Attach Script to Folder.scpt
Yvan KOENIG (VALLAURIS, France) lundi 8 octobre 2012 16:12:46