Don't create the new file if it has no data. Also make the Track portion optional so that the files do not become hidden with a ..

This commit is contained in:
Hyperling 2025-03-19 08:27:15 -07:00
parent 9fcb460c96
commit ab58617815

View File

@ -75,7 +75,7 @@ find "$OLD" -type f ! -name "*".mp3 | sort | while read file; do
if [[ $status != 0 ]]; then if [[ $status != 0 ]]; then
echo "*** FAILED: Exited with status '$status'." echo "*** FAILED: Exited with status '$status'."
echo "**** To troubleshoot, try running this:" echo "**** To troubleshoot, try running this:"
echo "ffmpeg -i '$file' '$file'.converted.mp3" echo "ffmpeg -i \"$file\" \"$file\".converted.mp3"
else else
echo "*** Success!" echo "*** Success!"
fi fi
@ -127,7 +127,9 @@ function migrate_music {
[[ ${#track} == 1 ]] && track="0$track" [[ ${#track} == 1 ]] && track="0$track"
echo "*** Track=$track" echo "*** Track=$track"
new_file="$track. $new_file" if [[ -s "$track" ]]; then
new_file="$track. $new_file"
fi
# Add the Album and Year. # Add the Album and Year.
album="" album=""
@ -209,6 +211,26 @@ function migrate_music {
new_file="$grandparent/$new_file" new_file="$grandparent/$new_file"
# Check that the file has proper data.
skip=false
if [[ -z "$grandparent" ]]; then
echo "ERROR: Could not find Artist information."
skip="true"
fi
if [[ -z "$parent" ]]; then
echo "ERROR: Could not find Album or Year information."
skip="true"
fi
if [[ -z "$track" && -z "$title" ]]; then
echo "ERROR: Could not find Track or Title information."
skip="true"
fi
if [[ "$skip" == "true" ]]; then
echo "*** Skipping file, critical data missing."
return 1
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/$grandparent/$parent"