我正在尝试找到一个脚本,当通过Hazel(在OS X上)运行时,在文件夹中查找文件类型.partial
,如果找不到,则标记内容该文件夹为绿色,以便Hazel可以用它做其他事情。
答案 0 :(得分:1)
在Applescript Editor
:
set myFolder to choose folder
tell application "Finder"
set folderContents to the entire contents of myFolder
end tell
set folderItems to the number of items in folderContents
set x to 1
repeat
set myFile to (item x of folderContents)
set theFileName to myFile as text
if (text ((offset of "." in theFileName) + 1) thru -1 of theFileName) is equal to "partial" then
return
end if
if x is equal to folderItems then exit repeat
set x to (x + 1)
end repeat
tell application "Finder"
set y to 1
repeat
set greenRepeat to item y of folderContents
set label index of greenRepeat to 6 --green
if y is equal to folderItems then exit repeat
set y to (y + 1)
end repeat
end tell
此脚本将告诉您选择一个文件夹。然后它会遍历该文件夹中的所有文件,如果找不到类型为.partial
的文件,它会将该文件夹中的所有文件的颜色设置为绿色。