Os objetos da pasta do Finder têm um atributo entire contents
no AppleScript e é fácil definir comentários do Spotlight e rótulos de cores.
set d to do shell script "date +%Y-%m-%d"
tell application "Finder"
set dir to POSIX file ((system attribute "HOME") & "/Documents/Test") as alias
repeat with f in entire contents of dir
if comment of f does not start with "Archived" then
set comment of f to "Archived " & d
set label index of f to 2
end if
end repeat
end tell
Versão do script da shell:
#!/bin/bash
d=$(date +%Y-%m-%d)
find ~/Documents/Test -exec osascript -e "on run argv
repeat with f in argv
tell app \"Finder\"
set f to (posix file (contents of f)) as alias
if comment of f does not start with \"Archived\" then
set comment of f to \"Archived $d\"
set label index of f to 2
end
end
end
end" '{}' +