OSX Automator Spotlight评论


1

(来自OSX 10.6.8)

我想设置一个Automator工作流程,将(“已存档”+当前日期)添加到根文件夹/文件和所有文件/子文件夹的聚光灯注释

除了

已存在“已存档”标记的位置。

这样我就可以在根文件夹上运行工作流,并且没有一堆“Archived”标签附加到所有堆叠的文件/文件夹中。

有什么想法吗?我试图过滤掉一些标签,然后继续运行基于其余部分的工作流程。


它必须在Automator中吗?
slhck

不必要。我不介意终端等的解决方案。虽然,我也希望也将文件/文件夹Label更改为Red,以便立即进行视觉确认。也许这也可以做到?
James

Answers:


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" '{}' +

谢谢你的配偶,今天早上我会看看这个!干杯。
James

真棒!作品,Lri你是一个传奇!
James
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.