music-library-tools/misc/fix_dates_deezer_dl.sh
2025-12-20 12:02:36 +02:00

35 lines
801 B
Bash

#!/bin/bash
BASE=/tmp/deezer-downloader/albums/
cd "$BASE" || exit 1
shopt -s nullglob
for dir in */ ; do
DATES=$(~/bin/exiftool/exiftool -Date "$dir"/*.flac "$dir"/*.mp3 2>/dev/null \
| awk -F': ' '{if($2!="") print $2}' | sort -u)
COUNT=$(echo "$DATES" | wc -l)
if [ "$COUNT" -le 1 ]; then
continue
fi
NEWDATE=$(echo "$DATES" | sort -nr | head -n1)
echo "🔧 $dir → Fixing inconsistent dates to newest: $NEWDATE"
echo "$DATES" | sed 's/^/ - /'
for f in "$dir"/*.flac; do
[ -f "$f" ] || continue
metaflac --remove-tag=DATE "$f"
metaflac --set-tag=DATE="$NEWDATE" "$f"
done
for f in "$dir"/*.mp3; do
[ -f "$f" ] || continue
id3v2 -T "$NEWDATE" "$f" >/dev/null 2>&1
done
echo
done