(*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get List of Finder Tags
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DATE: 2018-03-19
AUTHOR: ShaneStanley with minor mod by JMichaelTX
REF:
• How Can I get a List of All Finder Tags?
• Late Night Software Ltd.,
• http://forum.latenightsw.com/t/how-can-i-get-a-list-of-all-finder-tags/1192/2?u=jmichaeltx
TAGS: @List @Finder @Tags @ASObjC @Shane @AS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*)
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
set libPath to POSIX path of (path to library folder from user domain)
set libPath to current application's NSString's stringWithString:libPath
set prefsPath to libPath's stringByAppendingPathComponent:"SyncedPreferences/com.apple.finder.plist"
set theData to current application's NSData's dataWithContentsOfFile:prefsPath
set {theStuff, theError} to current application's NSPropertyListSerialization's propertyListWithData:theData options:0 |format|:(missing value) |error|:(reference)
if theStuff is missing value then error theError's localizedDescription() as text
set theTags to (theStuff's valueForKeyPath:"values.FinderTagDict.value.FinderTags.n")
--- Sort the Tag Array --- @JMichaelTX
set theTags to theTags's sortedArrayUsingSelector:"localizedStandardCompare:"
set tagList to theTags as list