Last active
December 18, 2015 14:18
-
-
Save pearkes/5795711 to your computer and use it in GitHub Desktop.
flactomp3 converts a directory of flac files into 320 mp3's. Installation instructions below.
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
#!/bin/sh | |
# Converts a directory of .flac files to the proprietary and lossy | |
# .mp3 format, retaining meta data. | |
# | |
# Note: Requires ffmpeg (brew/apt-get install ffmpeg) | |
# | |
# Use: | |
# | |
# flactomp3 DIRECTORY | |
# | |
# | |
# Fail fast | |
set -e | |
# Check to see if ffmpeg is kickin it here | |
if [ ! -f `type -P` ]; then | |
echo "You need to install ffmpeg (brew/apt-get install ffmpeg)" | |
exit | |
fi | |
# Is the first argument there, is it a dir? | |
if [ ! $1 ] || [ ! -d $1 ]; then | |
echo "Requires directory as first argument" | |
exit | |
fi | |
# Are there flac files in there? | |
if [ `ls -1 $1/*.flac 2>/dev/null | wc -l` = 0 ]; then | |
echo "There aren't any flac files in `pwd`/$1" | |
exit | |
fi | |
echo "Starting conversion..." | |
for file in $1/*.flac; | |
do | |
ffmpeg -i "$file" -ab 320k -map_metadata 0 "${file%.*}.mp3"; | |
done | |
echo "Finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment