• 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: other folder actions ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: other folder actions ?


  • Subject: Re: other folder actions ?
  • From: Stan Cleveland <email@hidden>
  • Date: Tue, 07 Mar 2017 17:37:21 -0800

On Mar 7, 2017, at 05:09 PM, 2551phil <email@hidden> wrote:

you’ll need a different automation tool and a different language. It’s fairly simple, and free to use.

Hi Jean-Christophe,

Actually, you can use AppleScript and a smattering of Shane's ASObjC, which as we know are also free to use. Try the code below as a starting point.

In simple terms, the script has an idle loop, which cycles every 5 seconds (or whatever you set it to). Each cycle, the script checks the current tags and compares them to the last know tags. If there's a difference, whatever action is needed can be taken.

Regards,
Stan C.

use AppleScript version "2.5" -- El Capitan
use scripting additions
use framework "Foundation"

property folderPath : "/Users/stanc/Desktop/Holder"
property existingTags : missing value

on run
set existingTags to returnTagsFor_(folderPath)
idle
end run

on idle
set folderPath to "/Users/stanc/Desktop/Holder"
set foundTags to returnTagsFor_(folderPath)
if existingTags is not foundTags then
set existingTags to foundTags -- update property
-- do whatever needs doing, when the tags change
set dialogMessage to "The tags have changed!"
displayDialog(dialogMessage, {"Cancel", "OK"}, "OK", 2)
end if
return 5 -- seconds until next check
end idle

------------------------------------------------------------------------------------------
-----------------------------------     HANDLERS     -----------------------------------
------------------------------------------------------------------------------------------
on displayDialog(dialogMessage, buttonList, defaultButton, iconNum)
activate
with timeout of 14400 seconds
display dialog dialogMessage buttons buttonList default button defaultButton with icon iconNum
end timeout
end displayDialog

on returnTagsFor:posixPath -- get the tags
-- handler by Shane Stanley, 2002-12-07
set aURL to current application's |NSURL|'s fileURLWithPath:posixPath -- make URL
set {theResult, theTags} to aURL's getResourceValue:(reference) forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
if theTags = missing value then return {} -- because when there are none, it returns missing value
return theTags as list
end returnTagsFor:

 _______________________________________________
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

References: 
 >other folder actions ? (From: Jean-Christophe Helary <email@hidden>)
 >Re: other folder actions ? (From: 2551phil <email@hidden>)

  • Prev by Date: Re: collectdata
  • Next by Date: Re: other folder actions ?
  • Previous by thread: Re: other folder actions ?
  • Next by thread: Re: other folder actions ?
  • Index(es):
    • Date
    • Thread