Skip to content

Instantly share code, notes, and snippets.

@JMichaelTX
Last active February 7, 2022 20:46
Show Gist options
  • Save JMichaelTX/0673b3e192d2becc3f5cf3d838782576 to your computer and use it in GitHub Desktop.
Save JMichaelTX/0673b3e192d2becc3f5cf3d838782576 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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