Replace backticks by $(…)

This commit is contained in:
fruchti 2020-01-18 21:42:45 +01:00
parent aa4d9bf371
commit 0fc278fa26

View file

@ -9,9 +9,9 @@ function transcode_to_mp3()
{ {
input_file="$1" input_file="$1"
output_directory="$2" output_directory="$2"
output_file="`echo "$input_file" | sed -E "s#^$input_directory(.+)\\.[a-z0-9]+\\$#$output_directory\\1.mp3#g"`" output_file="$(echo "$input_file" | sed -E "s#^$input_directory(.+)\\.[a-z0-9]+\\$#$output_directory\\1.mp3#g")"
directory="`dirname "$output_file"`" directory="$(dirname "$output_file")"
if [ ! -d "$directory" ] ; then if [ ! -d "$directory" ] ; then
echo "New Directory: \"$directory\"" echo "New Directory: \"$directory\""
mkdir -p "$directory" || { echo "Could not create directory \"$directory\"." ; return 1 ; } mkdir -p "$directory" || { echo "Could not create directory \"$directory\"." ; return 1 ; }
@ -28,10 +28,10 @@ function transcode_to_mp3()
fi fi
if [ "$transcode" = true ] ; then if [ "$transcode" = true ] ; then
input_type="`file -b --mime-type "$input_file"`" input_type="$(file -b --mime-type "$input_file")"
case "$input_type" in case "$input_type" in
"audio/flac"|"audio/x-flac") "audio/flac"|"audio/x-flac")
tmp_file="$tmp_directory/`basename "$output_file"`" tmp_file="$tmp_directory/$(basename "$output_file")"
echo "Transcoding MP3..." echo "Transcoding MP3..."
ffmpeg -hide_banner -loglevel fatal -i "$input_file" -y -b:a 320k -qscale:a 2 -id3v2_version 3 -f mp3 "$tmp_file" || { echo "Failed to transcode to \"$tmp_file\"." ; return 1 ; } ffmpeg -hide_banner -loglevel fatal -i "$input_file" -y -b:a 320k -qscale:a 2 -id3v2_version 3 -f mp3 "$tmp_file" || { echo "Failed to transcode to \"$tmp_file\"." ; return 1 ; }
mv -f "$tmp_file" "$output_file" || { echo "Could not move file to \"$output_file\"." ; return 1 ; } mv -f "$tmp_file" "$output_file" || { echo "Could not move file to \"$output_file\"." ; return 1 ; }
@ -61,7 +61,7 @@ function ogg_add_cover()
tmp_metafile="$tmp_directory/metadata" tmp_metafile="$tmp_directory/metadata"
tmp_mdimg="$tmp_directory/image-with-header" tmp_mdimg="$tmp_directory/image-with-header"
cover_mime_type="`file -b --mime-type "$cover_file"`" cover_mime_type="$(file -b --mime-type "$cover_file")"
description="" description=""
vorbiscomment --list --raw "$ogg_file" > "$tmp_metafile" && \ vorbiscomment --list --raw "$ogg_file" > "$tmp_metafile" && \
@ -87,9 +87,9 @@ function transcode_to_ogg()
{ {
input_file="$1" input_file="$1"
output_directory="$2" output_directory="$2"
output_file="`echo "$input_file" | sed -E "s#^$input_directory(.+)\\.[a-z0-9]+\\$#$output_directory\\1.ogg#g"`" output_file="$(echo "$input_file" | sed -E "s#^$input_directory(.+)\\.[a-z0-9]+\\$#$output_directory\\1.ogg#g")"
directory="`dirname "$output_file"`" directory="$(dirname "$output_file")"
if [ ! -d "$directory" ] ; then if [ ! -d "$directory" ] ; then
echo "New Directory: \"$directory\"" echo "New Directory: \"$directory\""
mkdir -p "$directory" || { echo "Could not create directory \"$directory\"." ; return 1 ; } mkdir -p "$directory" || { echo "Could not create directory \"$directory\"." ; return 1 ; }
@ -106,9 +106,9 @@ function transcode_to_ogg()
fi fi
if [ "$transcode" = true ] ; then if [ "$transcode" = true ] ; then
input_type="`file -b --mime-type "$input_file"`" input_type="$(file -b --mime-type "$input_file")"
tmp_ogg="$tmp_directory/`basename "$output_file"`" tmp_ogg="$tmp_directory/$(basename "$output_file")"
tmp_cover="$tmp_directory/cover" tmp_cover="$tmp_directory/cover"
case "$input_type" in case "$input_type" in
@ -172,8 +172,8 @@ if [ ! -d "$tmp_directory" ] ; then
fi fi
SAVEIFS=$IFS SAVEIFS=$IFS
IFS=`echo -ne "\n\b"` IFS=$(echo -ne "\n\b")
for file in `find "$input_directory" -name '*.flac' -or -name '*.mp3' | sort`; do for file in $(find "$input_directory" -name '*.flac' -or -name '*.mp3' | sort); do
transcode_to_mp3 "$file" "/data/mp3" || break transcode_to_mp3 "$file" "/data/mp3" || break
transcode_to_ogg "$file" "/data/ogg" || break transcode_to_ogg "$file" "/data/ogg" || break
done done