configs/arch-config/scripts/pieces/multi-ffmpeg.sh

50 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/bash
set -euo pipefail
2021-01-20 20:53:32 +01:00
# change into music raw folder
cd "$HOME/MusikRaw"
2021-01-19 21:29:58 +01:00
# number of parallel jobs can be set on as an argument
numjobs="$1"
# get directories
ls -d */ > directories
while read -r dir; do
# change into directory
cd "$dir"
# create directory in music
mkdir -p "$HOME/Musik/$dir"
# if there are $numjobs or more, dont spawn any new processes
while [[ $(jobs | wc -l) -gt $numjobs ]] ; do sleep 1 ; done
# convert m4a
if [[ $(ls | grep ".m4a") ]]; then
2021-01-20 21:17:56 +01:00
ffmpeg-normalize *.m4a -v -pr -c:a libopus -ext opus &
fi
# convert flac
if [[ $(ls | grep ".flac") ]]; then
2021-01-20 21:17:56 +01:00
ffmpeg-normalize *.flac -v -pr -c:a flac -ext flac &
fi
# convert opus
if [[ $(ls | grep ".opus") ]]; then
2021-01-20 21:17:56 +01:00
ffmpeg-normalize *.opus -v -pr -c:a libopus -ext opus &
fi
2021-01-21 19:23:43 +01:00
# link cover.jpg
if [[ -f cover.jpg ]]; then
ln -vf "$HOME/MusikRaw/$dir/cover.jpg" "$HOME/Musik/$dir/"
fi
# make symbolic link to music
ln -svf "$HOME/MusikRaw/$dir/normalized/"* "$HOME/Musik/$dir/"
# go back to music raw
cd "$HOME/MusikRaw"
done < directories
# remove directories file
rm directories
2021-01-19 21:29:58 +01:00
echo Finished!
exit