Skip to content

Instantly share code, notes, and snippets.

@IkezoeMakoto
Created February 2, 2020 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IkezoeMakoto/3d0a1c0451d3f91467289d04643b7293 to your computer and use it in GitHub Desktop.
Save IkezoeMakoto/3d0a1c0451d3f91467289d04643b7293 to your computer and use it in GitHub Desktop.
#!/bin/bash
dir_path="."
dirs=$(find $dir_path -mindepth 1 -maxdepth 1 -name '*.oma' -print0)
for file in $dirs;
do
targetName=${file#./}
encodeName=${targetName%.oma}.mp3
if [ -e "$encodeName" ]; then
continue;
fi
ffmpeg -i "$targetName" -vn -ac 2 -ar 48000 -ab 320k -acodec libmp3lame -f mp3 "$encodeName"
done
@KizahashiLuca
Copy link

こちらでデバッグしたところ、そうすると "あいまいなリダイレクト” でエラーが出たため、違う方向性からスクリプトを作成しました。
本当にありがとうございました。

なお自分で改良したスクリプトは、以下の通りです。

#!/bin/bash
IFS_BACKUP=$IFS
IFS=$'\n'
for f in $( find -maxdepth 3 | grep .OMA$ ); do
    if [ -e "${f%.OMA}.mp3" ]; then
        continue
    fi
    < /dev/null ffmpeg -i "${f}" -vn -ac 2 -ar 48000 -ab 320k -acodec libmp3lame -f mp3 "${f%.OMA}.mp3"
done
IFS=$IFS_BACKUP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment