2014-09-23 23:19:32 +02:00
|
|
|
#!/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
|
2014-12-09 14:04:26 +01:00
|
|
|
if [ -d "${ALBUM_NAME}" ]; then
|
2014-09-23 23:19:32 +02:00
|
|
|
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
|
2014-10-24 15:07:03 +02:00
|
|
|
for FILE in *.${OLD_FORMAT}
|
2014-09-23 23:19:32 +02:00
|
|
|
do
|
|
|
|
# -v error: display only if error
|
2014-09-28 14:12:13 +02:00
|
|
|
avconv -v "${LOG_LEVEL}" -i "${FILE}" -b "${BITRATE}" "${NEW_ALBUM_NAME}/${FILE%${OLD_FORMAT}}${NEW_FORMAT}"
|
2014-09-23 23:19:32 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
else
|
|
|
|
FILE="${ALBUM_NAME}"
|
2014-12-09 14:04:26 +01:00
|
|
|
if [ -f "${FILE}" ]; then
|
2014-09-23 23:19:32 +02:00
|
|
|
printf 'Convert %s to %s\n' "${FILE}" "${NEW_FORMAT}"
|
|
|
|
avconv -v "${LOG_LEVEL}" -i "${FILE}" -b "${BITRATE}" "${FILE%${OLD_FORMAT}}${NEW_FORMAT}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|