Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Finder Tag list from plist file. By @ShaneStanley
(*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
@JMichaelTX

This comment has been minimized.

Copy link
Owner Author

commented Apr 5, 2018

Comment to test for notifications.
made at 2018-04-05 01:12 GMT-0500.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.