我想写一些将检测某个指定目录中的新文件。我最好希望这个脚本能够无限期地继续运行,并且每当我看到一个新文件时,我都可以将它复制并移动到别的地方。我知道这一定是可能的,因为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脚本:获取文件夹的文件