Change output to left-lean better.

This commit is contained in:
Hyperling 2025-03-13 06:05:00 -07:00
parent bbb97b81c7
commit 92ac167e0f

View File

@ -17,18 +17,19 @@
## Facts and Variables ## ## Facts and Variables ##
DIR="`pwd`"
PROG="$(basename -- "${BASH_SOURCE[0]}")" PROG="$(basename -- "${BASH_SOURCE[0]}")"
FAIL=".$PROG.exit-error" FAIL=".$PROG.exit-error"
OLD="`pwd`/OLD" OLD="$DIR/OLD"
NEW="`pwd`/NEW" NEW="$DIR/NEW"
INT="`pwd`/INTERIM" INT="$DIR/INTERIM"
## Checks and Setup ## ## Checks and Setup ##
# System Packages # # System Packages #
echo "- Checking if necessary tools are installed." echo "* Checking if necessary tools are installed."
function needed_progs { function needed_progs {
cat <<- EOF cat <<- EOF
ffmpeg ffmpeg
@ -38,42 +39,45 @@ function needed_progs {
needed_progs | while read prog; do needed_progs | while read prog; do
if [[ -z "`which $prog`" ]]; then if [[ -z "`which $prog`" ]]; then
echo "ERROR: $prog not found, please install." echo "ERROR: $prog not found, please install."
touch .$PROG.exit-error touch $FAIL
fi fi
done done
if [[ -e .$PROG.exit-error ]]; then if [[ -e $FAIL ]]; then
rm -rf .$PROG.exit-error rm -fv $FAIL
exit 1 exit 1
fi fi
echo " - Tools are available." echo "** Tools are available."
# Old Directory # # Old Directory #
echo "- Checking whether OLD directory exists." echo "* Checking whether OLD directory exists."
if [[ "`pwd`"== */OLD ]]; then if [[ "`pwd`"== */OLD ]]; then
echo " - We are in the folder, moving up a directory." echo "** We are in the folder, moving up a directory."
cd .. cd ..
fi fi
if [[ ! -d OLD ]]; then if [[ ! -d OLD ]]; then
echo "ERROR: Could not find a folder named 'OLD'." echo "ERROR: Could not find a folder named 'OLD'."
echo " Please create it and add your library there." echo " Please create it and add your library there."
fi fi
echo " - Folder exists appropriately." echo "** Folder exists appropriately."
# Other Directories # # Other Directories #
echo "- Ensuring working directories NEW and INTERIM exist." echo "* Ensuring working directories NEW and INTERIM exist."
mkdir -pv $NEW $INT mkdir -pv $NEW $INT
## Convert Media ## ## Convert Media ##
echo "- Convert all files to mp3." echo "* Convert all files to mp3."
find "$OLD" ! -name "*".mp3 | while read file; do find "$OLD" ! -name "*".mp3 | while read file; do
ffmpeg -nostdin -hide_banner -loglevel quiet -i "$file" "$file".converted.mp3 ffmpeg -nostdin -hide_banner -loglevel quiet -i "$file" "$file".converted.mp3
done done
echo " - Done creating mp3s." echo "** Done creating mp3s."
## Transform Media ## ## Transform Media ##
echo "- Moving INTERIM files to NEW." echo "* Moving INTERIM files to NEW."
echo "- Copying OLD files to NEW." echo "** Done with INTERIM, deleting."
rm -rfv "$INT"
echo "* Copying OLD files to NEW."