Hier ist was ich getan habe. Es schien zu funktionieren (aber leider war der bpm-tag für viele Songs nicht genau genug).
#!/bin/bash cd /path/to/my/library while IFS= read -r -d '' FILE; do BPM=$(bpm-tag -f -n "$FILE" 2>&1 | sed "s/.mp3:/%/" | cut -d'%' -f2 | sed "s/ BPM//" | sed "s/^ //" | cut -d'.' -f1) #bpm-tag has its output in stderr, so I use 2>&1 to redirect it to stdout, then format it with sed and cut if [ "$BPM" -le 130 ] then cp "$FILE" /path/to/my/library/Slow/ elif [ "$BPM" -le 180 ] then cp "$FILE" /path/to/my/library/Medium/ else cp "$FILE" /path/to/my/library/Fast/ fi done < <(find . -type f -name '*.mp3' -print0)
Hier machen
while IFS= read -r -d '' FILE; do echo "$FILE" done < <(find . -type f -name '*.mp3' -print0)
druckt alle Dateien (-type f) mit der Endung .mp3 (-name '* .mp3'), die sich im Ordner oder in einem seiner Unterordner befinden. Wie ich es verstehe, sind die Optionen -print0 und -r -d '' für Formatierungszwecke, aber ich verstehe nicht wirklich, wie es funktioniert.