text 获取Finder标签列表(AppleScript)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 获取Finder标签列表(AppleScript)相关的知识,希望对你有一定的参考价值。

(*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
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

以上是关于text 获取Finder标签列表(AppleScript)的主要内容,如果未能解决你的问题,请参考以下文章

从样式标签中获取 css 类列表

如何在苹果Mac上打开多个Finder标签页

text 在Finder中复制文件的路径

text AppleScript在Finder中创建一个新文件(用于Automator)

text 在路径查找器中选择的Finder项目中显示(AppleScript)

python [整洁的Gmail标签]统一我的Gmail标签的可见性和命名(后来转换为macos finder标签)#gmail #label #tag