Files
Server-scripts/audiobook_metadata/metadata_album_from_folder.sh
T
Lucas Vivohost 7c2e0db615 metadata scripts
album from folder: create album from foldername
read: read and display author, album, grouping of every folder
remove author before title: remove "name - " when matching author
2026-09-14 12:43:38 +02:00

33 lines
832 B
Bash
Executable File

#!/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