Skip to content

Instantly share code, notes, and snippets.

Last active Nov 16, 2022
What would you like to do?
Convert a directory of .ogg files to .mp3 files
  • You need ffmpeg installed. If you have Homebrew installed on a Mac, you can do this by running:

    brew install ffmpeg
  • Put in directory containing .ogg files.

  • Ensure it's executable:

    chmod +x
  • Run it, to convert each .ogg file to a .mp3 file:

  • If a file is named track.ogg, the resulting .mp3 file will be saved in the same directory as track.mp3.

set -e
for f in *.ogg; do
out=$(echo $f | sed -e "s/.ogg/.mp3/g")
echo "Processing: $f"
ffmpeg -i "$f" -acodec libmp3lame "$out"
echo "Saved: $out"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment