此脚本将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
理想情况下,如果全部通过“执行shell脚本”运行会很棒。 还有任何想法如何在重命名为.aif时松开.wav?这些文件就是这样出来的; newfile.wav.aif
答案 0 :(得分:0)
路径上有sox
吗?我想不出find
命令无效的任何其他原因。
您可以将脚本编写为shell脚本:
set -e
dir=$(osascript -e 'tell app "Finder" to POSIX path of (target of Finder window 1 as alias)')
find "$dir" -type f | while read f; do
if [[ $f = *.wav ]]; then
sox "$f" "$dir$(basename "$f" .wav).aif" pad 0 2
rm "$f"
else
mv "$f" "$dir"
fi
done
rm -r "$dir"/*/