看到这个问题并意识到答案对我也很有用。这是我提出的Applescript。将其复制到Applescript Editor中,并调整两行变量theSearchPath
(第一行)和行尾的索引号,set label index
你应该好好去。
~/projects
在这种情况下,我正在搜索并将结果着色为绿色。
set theSearchPath to "/Users/Me/projects"
set theResults to do shell script "find " & quoted form of theSearchPath & " -name .git"
repeat with i from 1 to (count paragraphs of theResults)
set theResult to paragraph i of theResults
set theParentPath to text 1 through ((length of theResult) - 5) of theResult
set theParentAlias to POSIX file (theParentPath) as alias
tell application "Finder"
set label index of theParentAlias to 6
-- Set the last value of the above line to correspond with the color you want.
-- 0 is no color
-- 1 is orange
-- 2 is red
-- 3 is yellow
-- 4 is blue
-- 5 is purple
-- 6 is green
-- 7 is gray
end tell
end repeat
注意:尚未编写它以优雅地处理由find
命令吐出的错误。只要您正在搜索您拥有权限的目录,这应该不是问题。