• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I set folder action in Yosemite, please?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I set folder action in Yosemite, please?


  • Subject: Re: How do I set folder action in Yosemite, please?
  • From: Yvan KOENIG <email@hidden>
  • Date: Mon, 01 Dec 2014 12:34:21 +0100


Le 01/12/2014 à 04:11, Brian Christmas <email@hidden> a écrit :



G’day scripters

Thanks to Yvan, I’ve solved my problem.

However, two thing arose from trying to use Yvans MacScripter posting, and also merging ‘attach action’, which I posted....

1. If the ‘attach action’ is called more than once on a given folder, a second, third, fourth, etc, attachment is made. The command does not check that it’s already attached.

2. Yvans script did not restrict itself to folders within another folder, but was a 'blanket’ approach.

So, if you’re interested, this version restricts to a given folder, and checks if the Folder Action is already attached.

If anyone can spot any problems with the code, I’d appreciate knowing about it, please.

Regards

Santa

on run
set path2DesktopftpDownloadsFolder to ((path to desktop) & "ftp Downloads") as text # Our required Folder Actions folders container folder
set path2FolderActionsScriptsFolder to (path to Folder Action scripts folder) as text
tell application "Finder" to set everyftpDownloadsFolder to every folder of folder path2DesktopftpDownloadsFolder as list
tell application "System Events"
set p to 0
set folder actions enabled to true
set FolderActionNames to name of every folder action
set FolderActionPaths to path of every folder action
repeat with i from 1 to count FolderActionPaths
set item i of FolderActionPaths to item i of FolderActionPaths as text
end repeat
repeat with theFolderAction from 1 to count of everyftpDownloadsFolder
try
set eachFolderPath to item theFolderAction of everyftpDownloadsFolder as alias as text
set foundMatchingAction to false
set p to 1
if (count FolderActionPaths) > 0 then
set FAScripts to name of every script of folder action theFolderAction
else
set FAScripts to {}
end if
set p to 6
if "ftp Downloader.scpt" is not in FAScripts then
set p to 7
attach action to folder eachFolderPath using ((path2FolderActionsScriptsFolder & "ftp Downloader.scpt") as text)
end if
if foundMatchingAction then
set p to 10
if enabled of folder action eachAction is false then
set enabled of folder action eachAction to true
end if
end if
on error errmsg
display dialog "Setting Folder Action for 'ftp Downloads' folder folders. " & return & return & errmsg & "  p = " & p
end try
end repeat
end tell
 end run

____

Hello

I just extracted from the script delivered by Apple the required instructions.
I don't said that I gave a complete solution.
This is why I gave the path of the Apple's script so that every interested user may look at a more complete one.

I repeat that, from my point of view, continuing to use attach action to is a bad idea.
Maybe it will disappear one day and maybe changes will be made to it without any kind of documentation.
Always from my point of view, the need to use folder eachFolderPath when eachFolderPath was sufficient is documented.
I'm remembering a release note stating that now (maybe already with Mavericks) we are required to use true references to file objects (file, folder, alias wxyz) when old systems accepted a simple text object. The only problem with that is that the change was not applied as a whole. From one version to an other one, the new rule is applied which may be surprising but is not anormal.

Yvan KOENIG (VALLAURIS, France) lundi 1 décembre 2014 12:34:15



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: [rant] "Never mind the quality, feel the width!"
  • Next by Date: Re: ongoing Senior moments
  • Previous by thread: RE: [rant] "Never mind the quality, feel the width!"
  • Next by thread: Re: ongoing Senior moments
  • Index(es):
    • Date
    • Thread