Skip to content

Instantly share code, notes, and snippets.

@jdennes
Last active May 16, 2024 16:24
Show Gist options
  • Save jdennes/be4aa50f9aa0ca5d151cfba239dd34ec to your computer and use it in GitHub Desktop.
Save jdennes/be4aa50f9aa0ca5d151cfba239dd34ec to your computer and use it in GitHub Desktop.
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 process.sh in directory containing .ogg files.

  • Ensure it's executable:

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

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

#!/bin/bash
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"
done
@megasyntax
Copy link

megasyntax commented Jan 6, 2024

I want to add that to create the process.sh file in the best way possible:
you should open terminal, cd to the .ogg directory and type nano process.sh, in the terminal window, then paste the text on GitHub that is for the process.sh command, you can save the file by using Ctrl+X on keyboard, now start back at the step "Ensure it's executable" on Github.

I hope this helps, first post ever on GitHub <3

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