我想寫一些將檢測某個指定目錄中的新文件。我最好希望這個腳本能夠無限期地繼續運行,並且每當我看到一個新文件時,我都可以將它複製並移動到別的地方。我知道這一定是可能的,因爲Dropbox可以做到這一點,但我不知道如何得到這個工作或從哪裏開始。有任何想法嗎?Automator或Applescript,檢測文件夾中的新文件
2
A
回答
0
你正在尋找什麼(在將新文件添加到「熱文件夾」時產生Applescripts)稱爲「文件夾操作」,並且有許多教程可以在網上找到,應該指向你正確的方向。
例如,這裏是一個:"AppleScript: Exploring the power of Folder Actions, part I"
1
這裏是一個文件夾操作的另一個例子。您應該將腳本保存在〜/ Library/Scripts/Folder Action Scripts中。
on adding folder items to theFolder after receiving theFiles
-- This should make the folder action wait until large files have finished copying to the folder
set fSizes to {0}
repeat
tell application "System Events" to set end of fSizes to size of theFolder
if (item -1 of fSizes) = (item -2 of fSizes) then exit repeat
delay 1
end repeat
-- If you want to do something with each file ...
repeat with aFile in theFiles
-- your code goes here
end repeat
end adding folder items to
請記住,如果您的腳本將任何內容保存到目標文件夾,文件夾操作將再次觸發。
相關問題
- 1. Applescript文件夾操作使文件夾在新文件夾中?
- 2. 使用的Automator和AppleScript基於文件名的文件移動到文件夾
- 3. AppleScript選擇文件或文件夾
- 4. AppleScript/Automator文件夾將Excel轉換爲CSV的操作
- 5. Automator/Applescript文件排序和移動
- 6. Automator可變基於文件名(Applescript?)
- 7. 檢測CSV文件中新的子文件夾中的PowerShell
- 8. 檢查文件夾中的新文件
- 9. wx.TextCtrl中的自動檢測文件或文件夾路徑
- 10. 如何檢測Android中的文件或文件夾更改?
- 11. 隨着它們被添加到使用Automator或Applescript的文件夾中按順序重命名文件
- 12. 如何使用PHP來檢測文件夾中的新文件?
- 13. Automator,AppleScript或其他?
- 14. Automator檢查文件類型
- 15. 在文件夾操作中訪問Automator中的文件名
- 16. 的AppleScript從文件夾
- 17. AppleScript將每個文件移動到新文件夾中
- 18. 在UWP上檢測GridView上的文件夾或文件
- 19. Github沒有檢測到新文件夾
- 20. 如何監視新文件或文件夾的文件夾
- 21. Applescript:在多個文件夾中創建新的文件夾結構
- 22. 檢測文件或文件夾是否被更新的鉤子是什麼?
- 23. 在Automator中創建一個以指定文件名命名的新文件夾
- 24. AppleScript文件夾導航
- 25. 創建文件夾Applescript
- 26. AppleScript文件夾同步
- 27. zip文件夾使用applescript
- 28. 如何檢測文件夾?
- 29. 文件夾或文件夾
- 30. 的Automator服務,bash腳本:獲取文件夾的文件