0

このスクリプトは、WAV ファイルの名前を AIF に変更し、各ファイルの最後に 2 秒間の無音を追加してから、WAV ファイルを削除し、すべてのコンテンツをルート ディレクトリに移動し、空のフォルダーを削除します。

問題は、Applescripts 経由で「do shell script」行が実行されないことです。

do shell script "find " & rootDirectory & " -name \\*.wav -exec sox {} {}.aif pad 0 2 \\;"

「doスクリプト」として実行すれば問題ありません。

スクリプト:

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:

「Do Script」回避策:

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 を失う方法はありますか? ファイルはこのように出てきます。newfile.wav.aif

4

1 に答える 1

0

途中ですかsoxfindコマンドが機能しない他の理由は考えられません。

代わりに、スクリプトをシェル スクリプトとして記述できます。

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"/*/
于 2013-10-01T16:11:14.330 に答える