Begin using INTERIM directory.
This commit is contained in:
parent
e7fabe6f35
commit
ea9bcddfdc
@ -22,9 +22,13 @@ PROG="$(basename -- "${BASH_SOURCE[0]}")"
|
|||||||
|
|
||||||
FAIL=".$PROG.exit-error"
|
FAIL=".$PROG.exit-error"
|
||||||
|
|
||||||
OLD="$DIR/OLD"
|
OLD="OLD"
|
||||||
NEW="$DIR/NEW"
|
NEW="NEW"
|
||||||
INT="$DIR/INTERIM"
|
INT="INTERIM"
|
||||||
|
|
||||||
|
OLD_DIR="$DIR/$OLD"
|
||||||
|
NEW_DIR="$DIR/$NEW"
|
||||||
|
INT_DIR="$DIR/$INTERIM"
|
||||||
|
|
||||||
## Checks and Setup ##
|
## Checks and Setup ##
|
||||||
|
|
||||||
@ -62,15 +66,16 @@ 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_DIR" "$INT_DIR"
|
||||||
|
|
||||||
## Convert Media ##
|
## Convert Media ##
|
||||||
|
|
||||||
# TODO: Use the INTERIM folder folder, or remove references to it entirely.
|
# TODO: Use the INTERIM folder folder, or remove references to it entirely.
|
||||||
echo "* Ensure all files are mp3."
|
echo "* Ensure all files are mp3."
|
||||||
find "$OLD" -type f ! -name "*".mp3 | sort | while read file; do
|
find "$OLD_DIR" -type f ! -name "*".mp3 | sort | while read file; do
|
||||||
echo "** Working on '$file'."
|
echo "** Working on '$file'."
|
||||||
ffmpeg -y -nostdin -hide_banner -loglevel quiet -i "$file" "$file".converted.mp3
|
ffmpeg -y -nostdin -hide_banner -loglevel quiet -i "$file" \
|
||||||
|
"${file//$OLD/$INTERIM}".converted.mp3
|
||||||
status="$?"
|
status="$?"
|
||||||
if [[ $status != 0 ]]; then
|
if [[ $status != 0 ]]; then
|
||||||
echo "*** FAILED: Exited with status '$status'."
|
echo "*** FAILED: Exited with status '$status'."
|
||||||
@ -232,24 +237,24 @@ function migrate_music {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the new directories if they do not already exist.
|
# Create the new directories if they do not already exist.
|
||||||
mkdir -pv "$NEW/$grandparent/$parent"
|
mkdir -pv "$NEW_DIR/$grandparent/$parent"
|
||||||
|
|
||||||
# Move the file.
|
# Move the file.
|
||||||
new_file="$NEW/$new_file"
|
new_file="$NEW_DIR/$new_file"
|
||||||
$command -v "$file" "$new_file"
|
$command -v "$file" "$new_file"
|
||||||
|
|
||||||
echo "*** Finished file!"
|
echo "*** Finished file!"
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "* Moving INTERIM files to NEW."
|
echo "* Moving INTERIM files to NEW."
|
||||||
find "$INT" -name "*".mp3 | sort | while read file; do
|
find "$INT_DIR" -name "*".mp3 | sort | while read file; do
|
||||||
migrate_music "$file" mv
|
migrate_music "$file" mv
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "** Done with INTERIM, deleting."
|
echo "** Done with INTERIM, deleting."
|
||||||
rm -rfv "$INT"
|
rm -rfv "$INT_DIR"
|
||||||
|
|
||||||
echo "* Copying OLD files to NEW."
|
echo "* Copying OLD files to NEW."
|
||||||
find "$OLD" -name "*".mp3 | sort | while read file; do
|
find "$OLD_DIR" -name "*".mp3 | sort | while read file; do
|
||||||
migrate_music "$file" cp
|
migrate_music "$file" cp
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user