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
This commit is contained in:
Lucas Vivohost committed 2026-09-14 12:43:38 +02:00
1 parent 408566b6ea
commit 7c2e0db615
11 files changed
+114 -18

No files matched your search

+21 -7
View File
@@ -1,19 +1,33 @@
#!/usr/bin/env bash
root="${1:-.}"
find "$root" \( -iname '*.mp3' -o -iname '*.m4a' -o -iname '*.m4b' \) -print0 |
while IFS= read -r -d '' f; do
LIBRARY="${1:-.}"
mapfile -t FILES < <(
find "$LIBRARY" -type f \( \
-iname "*.mp3" -o \
-iname "*.m4b" -o \
-iname "*.m4a" \
\)
)
TOTAL=${#FILES[@]}
PROCESSED=0
for f in "${FILES[@]}"; do
((PROCESSED++))
if (( PROCESSED % 100 == 0 )); then
echo "Progress: $PROCESSED/$TOTAL files processed"
fi
comment=$(ffprobe -v error \
-show_entries format_tags=comment \
-of default=nw=1:nk=1 \
-- "$f")
shopt -s nocasematch
[[ $comment =~ ^[Rr]ead[[:space:]]+[Bb]y[[:space:]]+(.+) ]] || continue
[[ $comment =~ (read[[:space:]]+by|spoken[[:space:]]+by|narrated[[:space:]]+by|gesprochen[[:space:]]+von|gelesen[[:space:]]+von)[[:space:]]+([^.$'\n']*) ]] || continue
composer="${BASH_REMATCH[1]}"
echo "Updating: $f"
echo " Composer: $composer"
composer="${BASH_REMATCH[2]}"
composer="${composer%"${composer##*[!.,[:space:]]}"}"
printf '[%d/%d] [%s] %s | OLD="%s" | NEW="%s
"\n' "$PROCESSED" "$TOTAL" "Update" "$f" "$comment" "$composer"
dir=$(dirname -- "$f")
base=$(basename -- "$f")