环境与前提
系统:macOS 11.4
命令行工具:Tag (项目地址:https://github.com/jdberry/tag)
macOS上可以通过HomeBrew来安装:brew install tag
添加标签
choose from list {"Not Started", "Processing", "Delay", "Someday", "Completed"} default items {"Not Started"} with title "?Select Tags"
set tagname to result as text
tell application "Finder"
set sel to the selection as alias list
repeat with theItem in sel
do shell script "tag --add " & tagname & " " & (POSIX path of theItem)
end repeat
end tell
移除标签
tell application "Finder"
set sel to the selection as alias list
repeat with theItem in sel
do shell script "tag --set zero " & (POSIX path of theItem)
do shell script "tag --remove zero " & (POSIX path of theItem)
end repeat
end tell