Если Тип файла не существует, цвет метки зеленый - PullRequest
0 голосов
/ 04 декабря 2011

Я пытаюсь найти скрипт, который при запуске через Hazel (в OS X) ищет тип файла .partial в папке, и, если он не найден, пометьте содержимое эта папка зеленая, так что Хейзел сможет делать с ней другие вещи.

1 Ответ

1 голос
/ 05 декабря 2011

Запустите это в 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, он закрасит все файлы в этой папке зеленым цветом.

...