Add a script to convert a flac file (or all flac files in a directory)
to mp3.
This commit is contained in:
parent
064410359d
commit
5e1a08bf60
|
@ -0,0 +1,36 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ALBUM_NAME="${1}"
|
||||||
|
OLD_FORMAT="flac"
|
||||||
|
NEW_FORMAT="mp3"
|
||||||
|
NEW_ALBUM_NAME="${ALBUM_NAME}_${NEW_FORMAT}"
|
||||||
|
BITRATE="128k"
|
||||||
|
LOG_LEVEL="error"
|
||||||
|
|
||||||
|
## If it's an album
|
||||||
|
if [ -d ${ALBUM_NAME} ]; then
|
||||||
|
printf 'Convert %s to %s\n' "${ALBUM_NAME}" "${NEW_ALBUM_NAME}"
|
||||||
|
|
||||||
|
## Create the new directory
|
||||||
|
mkdir -p "${NEW_ALBUM_NAME}"
|
||||||
|
|
||||||
|
## Go to the album directory
|
||||||
|
pushd "${ALBUM_NAME}"
|
||||||
|
|
||||||
|
## For all files with the old format in the album directory
|
||||||
|
for file in *.${OLD_FORMAT}
|
||||||
|
do
|
||||||
|
# -v error: display only if error
|
||||||
|
avconv -v "${LOG_LEVEL}" -I "${FILE}" -B "${BITRATE}" "${NEW_ALBUM_NAME}/${FILE%${OLD_FORMAT}}${NEW_FORMAT}"
|
||||||
|
done
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
|
else
|
||||||
|
FILE="${ALBUM_NAME}"
|
||||||
|
if [ -f ${FILE} ]; then
|
||||||
|
printf 'Convert %s to %s\n' "${FILE}" "${NEW_FORMAT}"
|
||||||
|
avconv -v "${LOG_LEVEL}" -i "${FILE}" -b "${BITRATE}" "${FILE%${OLD_FORMAT}}${NEW_FORMAT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
Loading…
Reference in New Issue