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