Skip to content

Instantly share code, notes, and snippets.

@AlexandreRio
Forked from SyBen/flacToMP3
Last active January 4, 2016 02:59
Show Gist options
  • Save AlexandreRio/8559248 to your computer and use it in GitHub Desktop.
Save AlexandreRio/8559248 to your computer and use it in GitHub Desktop.
#!/bin/bash
#License CC-BY-NC-SA for the code.
#This script converts all flac files in a directory into 320kpbs mp3 files, and then move them into another directory,
#set as the first argument. The occurences of words Flac and FLAC will be replace in the name of the working director.y
#considering wd is /path/nameOfDirectory-FLAC, the new directory will be $1/nameOfDirectory-mp3.
#Needs 1 parameter : the path to save the directory containing the mp3 files.
if [ $# -eq 1 ]; then
currentPath=`pwd`
currentFolder=${currentPath##*/}
destFolder=${currentFolder//FLAC|Flac/mp3}
for f in *.flac; do
ffmpeg -i "$f" -ab 320k "${f%.flac}.mp3";
done
mkdir "$destFolder"
mv *.mp3 "$destFolder"
mv "$destFolder" $1
else
echo -e "Usage: move to the directory with your flach files, then call\n\t./flacToMP3.sh dest_dir"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment