此脚本是将WAV文件重命名为AIF并在每个文件末尾添加2秒静音,然后删除WAV文件并将所有内容移动到根目录并删除空文件夹。
问题是通过 Applescripts “do shell script”行不执行。
do shell script "find " & rootDirectory & " -name \\*.wav -exec sox {} {}.aif pad 0 2 \\;"
如果我将它作为“执行脚本”运行,那很好。
剧本:
tell application "Finder" to set rootDirectory to (target of Finder window 1) as string
set rootDirectory to quoted form of POSIX path of rootDirectory
do shell script "find " & rootDirectory & " -name \\*.wav -exec sox {} {}.aif pad 0 2 \\;" -- change to AIF and add 2 second silence
delay 10
do shell script "find " & rootDirectory & " -name \\*.wav -exec rm {} \\;" -- delete WAV files
delay 5
do shell script "find " & rootDirectory & " -type f -exec mv {} " & rootDirectory & " \\;" --Move all files into rootDirectory
do shell script "find " & rootDirectory & " -depth -type d -exec rmdir {} " & " \\;" -- Remove all subdirectories of XMoveTo Root.app:
“执行脚本”解决方法:
tell application "Terminal"
activate
do script "find " & rootDirectory & " -name \\*.wav -exec sox {} {}.aif pad 0 2 \\;" in front window
delay 10
do script "find " & rootDirectory & " -name \\*.wav -exec rm {} \\;" in front window
end tell
理想情况下,如果这一切都通过“do shell script”运行,那就太好了。还有任何想法在重命名为 .aif 时如何释放 .wav?文件是这样出来的;新文件.wav.aif