Last active
February 23, 2018 13:54
-
-
Save meise/d529938e2a49abcd8fdcb6ab58854649 to your computer and use it in GitHub Desktop.
convert flac directories 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
#!/bin/bash | |
# Convert all flac files in a directory structure into mp3 and take folder | |
# structure. | |
SOURCE_DIR=$1 | |
DEST_DIR=$2 | |
if [ $# -eq 0 ]; then | |
echo "Usage: ${0} source_dir destination_dir" | |
exit 1 | |
fi | |
for sub_dir in $(find ${SOURCE_DIR} -mindepth 1 -type d); do | |
dst_dir="${DEST_DIR}/$(basename ${SOURCE_DIR})/$(echo $sub_dir | sed "s|^${SOURCE_DIR}|./|g")" | |
mkdir -p $dst_dir | |
echo | |
echo | |
echo $dst_dir | |
echo | |
for file in ${sub_dir}/*.flac; do | |
ffmpeg -y -i "$file" -qscale:a 0 "$dst_dir/$(basename "${file[@]/%flac/mp3}")" | |
echo | |
echo | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment