commit 98a884ff433dbf62b99f50ec4386116665b21a13 parent db13088e59730b3af879b508d0e2268fc47e059f Author: Alex Balgavy <alex@balgavy.eu> Date: Sat, 2 Jan 2021 19:53:13 +0100 mp3-tags-to-folders: replace problematic chars Also allow specifying where to look and where to put files. Diffstat:
M | scripts/mp3-tags-to-folders | | | 10 | +++++----- |
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/scripts/mp3-tags-to-folders b/scripts/mp3-tags-to-folders @@ -1,16 +1,16 @@ #!/bin/sh die() { printf "%s\n" "$1" >&2; exit 1; } command -v ffprobe 1>/dev/null 2>&1 || die "ffprobe not installed." -[ $# -eq 1 ] || die "Argument required: path to music directory" +[ $# -eq 2 ] || die "Arguments required: path to music directory, path to destination" [ -d "$1" ] || die "Path $1 is not a directory." set -x -cd "$1" || die "Could not cd to $1" +cd "$2" || die "Could not cd to $1" mkdir -p _failed || die "Directory ./_failed already exists" -find . -name "*.mp3" 2>/dev/null | \ +find "$1" -name "*.mp3" 2>/dev/null | \ while read -r i; do - artist="$(ffprobe -loglevel error -show_entries format_tags=artist -of default=noprint_wrappers=1:nokey=1 "$i" | tr -d ':' | tr '!@#$%^&*:?' '_')" + artist="$(ffprobe -loglevel error -show_entries format_tags=artist -of default=noprint_wrappers=1:nokey=1 "$i" | tr -d ':' | tr '!@#$%^&*:?"' '_')" [ $? -eq 0 ] || { mv "$i" _failed/ && continue; } - album="$(ffprobe -loglevel error -show_entries format_tags=album -of default=noprint_wrappers=1:nokey=1 "$i" | tr -d ':' | tr '!@#$%^&*:?' '_')" + album="$(ffprobe -loglevel error -show_entries format_tags=album -of default=noprint_wrappers=1:nokey=1 "$i" | tr -d ':' | tr '!@#$%^&*:?"' '_')" [ $? -eq 0 ] || { mv "$i" _failed/ && continue; } mkdir -p "$artist/$album" mv "$i" "$artist/$album"