
Ich möchte in allen Songs mit dem Genretag X im Ordner ~/msk rekursiv eben jenes Genretag durch Y ersetzen. Gibt's da was? Kann auch Kommandozeile sein.
Keine wirkliche hilfe für Massentagging aberdasebastian hat geschrieben: Kann auch Kommandozeile sein
Sieh Dir mal
Code: Alles auswählen
#!/bin/bash
# Ändere die Genres hier
declare -A genres
genres=( ["Pop"]="pop" ["Voixmusi"]="voix" ["Rock"]="rock" )
# Setze den absoluten Pfad zu deinem Musikverzeichnis
music_dir="/home/sebastian/dwn/test"
# Durchlaufe alle MP3-Dateien im Musikverzeichnis
find "$music_dir" -name "*.mp3" | while read -r file; do
for old_genre in "${!genres[@]}"; do
new_genre=${genres[$old_genre]}
# Lese das aktuelle Genre
current_genre=$(id3v2 -l "$file" | grep "Genre" | awk -F ': ' '{print $2}')
# Wenn das aktuelle Genre dem alten Genre entspricht, ändere es
if [[ "$current_genre" == "$old_genre" ]]; then
id3v2 -g "$new_genre" "$file"
echo "Ändere Genre von '$old_genre' zu '$new_genre' in '$file'"
fi
done
done
Nachdem ich dann auch die Manpage von id3v2 überflogen und dort nur etwas von "genre num" gelesen hatte, hatte ich das Skript auch schon wieder ad acta gelegt. Zwei, dreimal hat mich so generierter Bashcode aber auf die richtige Spur gebracht.rodney hat geschrieben:01.12.2024 20:17:30id3v2 zeigt mit der Option -l kein ... mit der Option -g "Genrename" nichts anfangen ... warum man nicht mal in Betracht ziehen sollte Ki generierten Code ...
Genau so was kanndasebastian hat geschrieben:01.12.2024 13:27:42.... Genretag X im Ordner ~/msk rekursiv eben jenes Genretag durch Y ersetzen.
Code: Alles auswählen
#!/usr/bin/env bash
# Aufruf mit ./scriptname <verzeichnis> <zu aendernder tag> <neuer tag>
workdir=${1:-.}
old_genre=${2:-altesgenre}
new_genre=${3:-neuesgenre}
getgenre () {
eyeD3 --no-color "$@" | \
grep -E "\sgenre:\s" | \
sed 's/^.*genre:\ \([^(]*\).*/\1/;s/\s\+//'
}
for file in $(find "${workdir}" -iname "*.mp3"); do
current_genre="$(getgenre ${file})"
if [ "${current_genre}" == "${old_genre}" ]; then
eyeD3 -G "${new_genre}" "${file}"
fi
done
Das ist ja cool, danke für den Versuch.rodney hat geschrieben:02.12.2024 19:39:04... (hat mit script . "Pop/Rock" "Rambazamba" funktioniert
Code: Alles auswählen
for file in "$(find "${workdir}" -iname "*.mp3")"; do
Und auf die kommt's gerade bei Musik besonders an ...
Abgesehen davon, daß ich nicht bereit bin, ein Gerät zu ersetzen, das prinzipiell seinen Dienst tut, stimme ich dir zu, was die Musik betrifft. Auch Coverart wird wird ja überbewertet. Ironie off.GregorS hat geschrieben:03.12.2024 19:02:56Und auf die kommt's gerade bei Musik besonders an ... Die Dinge haben sich nach mir zu richten, nicht umgekehrt.
Ich habe gerade die Zeit gefunden, das auszuprobieren, das Problem bleibt im Wesentlichen dasselbe, allerdings wird jetzt gleich mal abgebrochen (file not found...) anstatt alles durchzuprobieren.
Code: Alles auswählen
shopt -s globstar
for file in "${workdir}"/**/*.mp3; do
Das ändert die Sache natürlich gewaltig.dasebastian hat geschrieben:04.12.2024 06:55:17... Ich bin aber nicht der einzige hier im Haus/Auto, der meine Musiksammlung hört und durchstöbert ...GregorS hat geschrieben:03.12.2024 19:02:56Und auf die [Optik] kommt's gerade bei Musik besonders an ... Die Dinge haben sich nach mir zu richten, nicht umgekehrt.
Code: Alles auswählen
$ cat dwn/changetags
#!/usr/bin/env bash
# Aufruf mit ./scriptname <verzeichnis> <zu aendernder tag> <neuer tag>
shopt -s globstar
workdir=${1:-.}
old_genre=${2:-altesgenre}
new_genre=${3:-neuesgenre}
getgenre () {
eyeD3 --no-color "$@" | \
grep -E "\sgenre:\s" | \
sed 's/^.*genre:\ \([^(]*\).*/\1/;s/\s\+//'
}
for file in "${workdir}"/**/*.mp3; do
# for file in "$(find "${workdir}" -iname "*.mp3")"; do
# for file in $(find "${workdir}" -iname "*.mp3"); do
current_genre="$(getgenre ${file})"
if [ "${current_genre}" == "${old_genre}" ]; then
eyeD3 -G "${new_genre}" "${file}"
fi
done
$ ll dwn/test
insgesamt 24K
drwxr-xr-x 6 sebastian sebastian 4,0K 2024-12-04 19:12 ./
drwxr-xr-x 3 sebastian sebastian 4,0K 2024-12-04 19:04 ../
drwxr-xr-x 3 sebastian sebastian 4,0K 2024-12-03 06:51 "5 8erl In Ehr'n"/
drwxr-xr-x 4 sebastian sebastian 4,0K 2024-12-03 06:51 '5K HD'/
drwxr-xr-x 3 sebastian sebastian 4,0K 2024-12-03 06:51 'Anda Morts'/
drwxr-xr-x 3 sebastian sebastian 4,0K 2024-12-03 06:51 Blumfeld/
$ . dwn/changetags /home/sebastian/dwn/test "Pop" "hulapalula"
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/5K
file not found: /home/sebastian/dwn/test/Anda
file not found: /home/sebastian/dwn/test/Anda
file not found: /home/sebastian/dwn/test/Anda
file not found: /home/sebastian/dwn/test/Anda
file not found: /home/sebastian/dwn/test/Anda
file not found: /home/sebastian/dwn/test/Anda
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
file not found: /home/sebastian/dwn/test/Blumfeld/L'
$
GregorS hat geschrieben:04.12.2024 11:51:11Das ändert die Sache natürlich gewaltig ... kann ich mir eine gewisse Hochnäsigkeit leisten.
Alles gut, das ist völlig ok!dasebastian hat geschrieben:04.12.2024 19:25:47Ich gebe hier nur Feedback tobo und will dich ausdrücklich nicht triggern.
Code: Alles auswählen
current_genre="$(getgenre "${file}")"
tobo you did it!
Code: Alles auswählen
#!/usr/bin/env bash
# Aufruf mit ./scriptname <verzeichnis> <zu aendernder tag> <neuer tag>
shopt -s globstar
workdir=${1:-.}
old_genre=${2:-altesgenre}
new_genre=${3:-neuesgenre}
getgenre () {
eyeD3 --no-color "$@" | \
grep -E "\sgenre:\s" | \
sed 's/^.*genre:\ \([^(]*\).*/\1/;s/\s\+//'
}
for file in "${workdir}"/**/*.mp3; do
# for file in "$(find "${workdir}" -iname "*.mp3")"; do
# for file in $(find "${workdir}" -iname "*.mp3"); do
current_genre="$(getgenre "${file}")"
# current_genre="$(getgenre ${file})"
if [ "${current_genre}" == "${old_genre}" ]; then
eyeD3 -G "${new_genre}" "${file}"
fi
done
Code: Alles auswählen
$ . dwn/changetags /home/sebastian/dwn/test "Pop" "hulapalula"
Code: Alles auswählen
find "${workdir}" -iname "*.mp3" | while read -r line; do
Du meinst statt "for file in "${workdir}"/**/*.mp3; do"?
Code: Alles auswählen
#!/usr/bin/env bash
# braucht eyed3 installiert, man eyeD3
# https://debianforum.de/forum/viewtopic.php?t=191062
# Aufruf mit . /scriptname /verzeichnis/zu/mucke "zu aendernder tag" "neuer tag"
shopt -s globstar
workdir=${1:-.}
old_genre=${2:-altesgenre}
new_genre=${3:-neuesgenre}
getgenre () {
eyeD3 --no-color "$@" | \
grep -E "\sgenre:\s" | \
sed 's/^.*genre:\ \([^(]*\).*/\1/;s/\s\+//'
}
for file in "${workdir}"/**/*.mp3; do
current_genre="$(getgenre "${file}")"
if [ "${current_genre}" == "${old_genre}" ]; then
eyeD3 -G "${new_genre}" "${file}"
fi
done