2013-10-07 17 views
1

我是新來的AppleScript,但我想建立一個文件夾操作是:Applescripting提醒作爲添加 - 文件夾操作

1. Recognises when a file is added to a folder 
2. Tags said folder red 
3. Adds a Reminder to the "Downloads" reminder list that has the name of the newly-added file as the body text of the reminder 

使用谷歌和AppleScript的記錄功能到目前爲止,我frankenscripted了一起

property dialog_timeout : 30 -- set the amount of time before dialogs auto-answer. 

on adding folder items to this_folder after receiving added_items 



try 
    tell application "Finder" 
     set FILEname to name of (added_items) 
     set label index of folder "untitled folder" of folder "Desktop" of folder "heyjeremyoates" of folder "Users" of startup disk to 2 
    end tell 

    tell application "Reminders" 
     set mylist to list "Downloads" 
     tell mylist 
      make new reminder with properties {name:"D/L Complete", body:FILEname, due date:(current date)} 
     end tell 
    end tell 
end try 

end adding folder items to 

該死的事情將無法正常工作。真氣。我測試它作爲文件夾動作與「測試」作爲提醒的名稱和正文,它工作得很好。我很肯定我在設置FILEname作爲新複製項目的名稱時出錯了,因爲現在腳本不再將文件夾變成紅色。

這個背後的想法是,我可以從我的iPhone/iPad上看到多少大型/計劃的下載到我的家庭MAC(包括種子和大型工作文件 - 我將有一個單獨的文件夾操作和提醒列表每個下載文件夾)還有那些還沒有被管理。

如果iCloud/Reminders和十幾行代碼可以提供我想要的東西,似乎設置一個Growl/Prowl組合是浪費。理想情況下,我會寫第二個applescript,當我重命名或移動相關文件時將刪除提醒,雖然我甚至沒有想過如果任何人有任何建議它會如何工作,我會超級感激

可惜的是你不能(本身)有OSX通知推到鏈接到同一個iCloud帳戶,但(與適當的粒度)的iOS設備

但是,我離題 - 任何人都可以看到我很差勁上面這兒?

預先感謝甚至讀了這麼遠

回答

1

added_items是別名的列表,並name of (added_items)導致錯誤。

on adding folder items to this_folder after receiving added_items 
    tell application "Finder" 
     set label index of this_folder to 2 
     repeat with f in added_items 
      set n to name of f 
      tell application "Reminders" to tell list "Downloads" 
       make new reminder with properties {name:"D/L Complete", body:n, due date:(current date)} 
      end tell 
     end repeat 
    end tell 
end adding folder items to 

(保存腳本~/Library/Workflows/Applications/Folder Actions/並允許從文件夾操作設置該文件夾的動作。)

+0

感謝您的答覆勞裏,我最終得到幫助,從DJ在Bazzie Wazzie在macscripter.net這個問題論壇。最終的代碼是http://macscripter.net/viewtopic.php?pid=167407#p167407後的#6,但解決方案几乎與你的相同:D – user2853816