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

Re: fsitem ?


  • Subject: Re: fsitem ?
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 25 Feb 2017 13:42:18 +1100

On 25 Feb 2017, at 1:07 pm, Jean-Christophe Helary <email@hidden> wrote:

Does that mean that both applications only rely on what the file system is feeding them without trying to get more of the item metadata ?

I don't know either, but my suspicion would be that they simply haven't kept up. Not that tags are hard to do:

use AppleScript version "2.3.1"
use scripting additions
use framework "Foundation"

on returnTagsFor:posixPath -- get the tags
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:

on setTags:tagList forPath:posixPath -- set the tags, replacing any existing
set aURL to current application's |NSURL|'s fileURLWithPath:posixPath -- make URL
aURL's setResourceValue:tagList forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
end setTags:forPath:

on addTags:tagList forPath:posixPath -- add to existing tags
set aURL to current application's |NSURL|'s fileURLWithPath:posixPath -- make URL
-- get existing tags
set {theResult, theTags} to aURL's getResourceValue:(reference) forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
if theTags ≠ missing value then -- add new tags
set tagList to (theTags as list) & tagList
set tagList to (current application's NSOrderedSet's orderedSetWithArray:tagList)'s allObjects() -- delete any duplicates
end if
aURL's setResourceValue:tagList forKey:(current application's NSURLTagNamesKey) |error|:(missing value)
end addTags:forPath:

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
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: 
 >fsitem ? (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: Replacement for Finder?
  • Next by Date: Re: Replacement for Finder?
  • Previous by thread: fsitem ?
  • Next by thread: Re: fsitem ?
  • Index(es):
    • Date
    • Thread