Script to check number of tags

This is an embedded script to check how many tags a file has. As configured it specifically checks if the file has 1 tag but can easily be changed to check for other values.
Note the shell uses "Tag", a command line tool to manage tags in macOS. You can download it here: https://github.com/jdberry/tag.
- Code: Select all
tell application "Finder"
set cmd to "/usr/local/bin/Tag -l -N" & space & quote & (POSIX path of theFile) & quote
set tagList to do shell script cmd
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set tagCount to (count tagList's text items)
set AppleScript's text item delimiters to astid
if tagCount = 1 then return true
end tell
Note the shell uses "Tag", a command line tool to manage tags in macOS. You can download it here: https://github.com/jdberry/tag.