(AppleScript) 使用 shell 脚本从子文件夹中删除文件
(AppleScript) Remove files from subfolders with shell script
我有一个将文件移动到回收站的脚本,但我要处理数以万计的文件,所以我需要它来快速完成。当前脚本使 Finder 卡住,我每次使用该脚本时都需要重新启动 Finder。
set source_folder to POSIX path of (path to pictures folder) & "4K Stogram"
do shell script "/usr/bin/find " & quoted form of source_folder & " -type f -exec /bin/mv {} ~/.Trash \;"
display notification "All images were processed." with title "New" sound name "Glass.aiff"
tell me to quit
shell 脚本的 'rm -f' 命令不会让它更快吗?
如果是,脚本应该是什么样子?
无论如何,我不需要回收站中的那些文件,我会在脚本完成工作后立即删除它们。
您应该可以pipe your find results rm 命令。明白虽然rm应该更快,但它是永久的。在调用它之前确保您的代码是正确的。
将 -delete
选项添加到 find
命令。
像这样:
set source_folder to POSIX path of (path to pictures folder) & "4K Stogram"
do shell script "/usr/bin/find " & (quoted form of source_folder) & " -type f -delete"
我有一个将文件移动到回收站的脚本,但我要处理数以万计的文件,所以我需要它来快速完成。当前脚本使 Finder 卡住,我每次使用该脚本时都需要重新启动 Finder。
set source_folder to POSIX path of (path to pictures folder) & "4K Stogram"
do shell script "/usr/bin/find " & quoted form of source_folder & " -type f -exec /bin/mv {} ~/.Trash \;"
display notification "All images were processed." with title "New" sound name "Glass.aiff"
tell me to quit
shell 脚本的 'rm -f' 命令不会让它更快吗? 如果是,脚本应该是什么样子? 无论如何,我不需要回收站中的那些文件,我会在脚本完成工作后立即删除它们。
您应该可以pipe your find results rm 命令。明白虽然rm应该更快,但它是永久的。在调用它之前确保您的代码是正确的。
将 -delete
选项添加到 find
命令。
像这样:
set source_folder to POSIX path of (path to pictures folder) & "4K Stogram"
do shell script "/usr/bin/find " & (quoted form of source_folder) & " -type f -delete"