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"
|
||||
|
||||
OLD="$DIR/OLD"
|
||||
NEW="$DIR/NEW"
|
||||
INT="$DIR/INTERIM"
|
||||
OLD="OLD"
|
||||
NEW="NEW"
|
||||
INT="INTERIM"
|
||||
|
||||
OLD_DIR="$DIR/$OLD"
|
||||
NEW_DIR="$DIR/$NEW"
|
||||
INT_DIR="$DIR/$INTERIM"
|
||||
|
||||
## Checks and Setup ##
|
||||
|
||||
@ -62,15 +66,16 @@ echo "** Folder exists appropriately."
|
||||
|
||||
# Other Directories #
|
||||
echo "* Ensuring working directories NEW and INTERIM exist."
|
||||
mkdir -pv "$NEW" "$INT"
|
||||
mkdir -pv "$NEW_DIR" "$INT_DIR"
|
||||
|
||||
## Convert Media ##
|
||||
|
||||
# TODO: Use the INTERIM folder folder, or remove references to it entirely.
|
||||
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'."
|
||||
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="$?"
|
||||
if [[ $status != 0 ]]; then
|
||||
echo "*** FAILED: Exited with status '$status'."
|
||||
@ -232,24 +237,24 @@ function migrate_music {
|
||||
fi
|
||||
|
||||
# Create the new directories if they do not already exist.
|
||||
mkdir -pv "$NEW/$grandparent/$parent"
|
||||
mkdir -pv "$NEW_DIR/$grandparent/$parent"
|
||||
|
||||
# Move the file.
|
||||
new_file="$NEW/$new_file"
|
||||
new_file="$NEW_DIR/$new_file"
|
||||
$command -v "$file" "$new_file"
|
||||
|
||||
echo "*** Finished file!"
|
||||
}
|
||||
|
||||
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
|
||||
done
|
||||
|
||||
echo "** Done with INTERIM, deleting."
|
||||
rm -rfv "$INT"
|
||||
rm -rfv "$INT_DIR"
|
||||
|
||||
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
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user