Files
Server-scripts/audiobook_metadata/metadata_album_from_folder.sh
T

32 lines
832 B
Bash
Raw Normal View History

2026-09-14 12:22:45 +02:00
#!/bin/bash
cd $1
for d in */; do
album="${d%/}"
# Remove leading numbering: "001 - "
album=$(echo "$album" | sed -E 's/^[0-9]+[[:space:]]*-[[:space:]]*//')
album=$(echo "$album" | sed -E 's/^\([^)]*\)[[:space:]]*//; s/[[:space:]]*\([^)]*\)$//')
# Remove all (...) groups
album=$(echo "$album" | sed -E 's/$$[^)]*$$//g')
# Remove all [...] groups
album=$(echo "$album" | sed -E 's/$$[^]]*$$//g')
# Remove standalone years
album=$(echo "$album" | sed -E 's/[[:space:]]+[12][0-9]{3}//g')
# Collapse multiple spaces and trim
album=$(echo "$album" | sed -E 's/[[:space:]]+/ /g; s/^ //; s/ $//')
echo "Setting album: $album"
cd "$d" || continue
for x in *; do
[ -f "$x" ] || continue
kid3-cli -c "set album \"$album\"" -c save "$x"
done
cd ..
done