Created
May 14, 2017 13:44
-
-
Save hultberg/482317e1f37fb21c1cd3bd323564bed8 to your computer and use it in GitHub Desktop.
Convert .ogg to .mp3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Convert all .ogg files in current folder to mp3, and move the original .ogg file into own folder named "ogg". | |
# Stop on error (-e). | |
# Debug each command (-x). | |
set -ex | |
# Make sure there is a ogg folder available. | |
if [[ ! -d "ogg" ]]; then | |
mkdir ogg | |
fi | |
for f in *.ogg | |
do | |
# Determine the mp3 filename, replace .ogg with .mp3. | |
# This expects that the file contains .ogg at the end | |
newfilename=$(echo "$f" | sed -e 's/\.ogg/\.mp3/g') | |
# This support spaces in the filename. | |
ffmpeg -i "$f" -acodec libmp3lame "$newfilename" | |
# Move the original ogg into own folder. | |
mv "$f" ogg | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment