(来自 OSX 10.6.8)
我想设置一个 Automator 工作流程,将(“已存档”+当前日期)添加到根文件夹/文件以及所有文件/子文件夹的聚光灯注释
除了
其中已存在“已存档”标签。
这样我就可以在根文件夹上运行工作流,而不会将一堆“已存档”标签附加到所有堆积的文件/文件夹中。
有什么想法吗?我正在尝试过滤掉一些标签,然后继续根据剩余部分运行工作流程。
答案1
Finder 文件夹对象entire contents
在 AppleScript 中有一个属性,可以轻松设置 Spotlight 注释和颜色标签。
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
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" '{}' +