dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 15f30ab4fdb729b627797f0e97e736cc65d674da
parent b582282c367e07bef7c65df7c02c375963ebf31c
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Wed,  4 Jan 2023 16:55:08 +0100

mlm: also replace filename

Diffstat:
Mscripts/mlm | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/scripts/mlm b/scripts/mlm @@ -86,6 +86,7 @@ verify_playlist() { lns="$(wc -l < "$playlist_path" | tr -d '[:space:]')" ctr=1; while read -r f; do + f="$(printf '%s' "$f" | tr -d '\r\n')" printf '%s' "$f" | grep '^#' >/dev/null 2>&1 && { ctr=$((ctr+1)); continue; } printf "\r%d/%d" $ctr "$lns" stat "$MUSIC_DIR/$f" >/dev/null 2>&1 || printf "\t%s\n" "$f"; @@ -113,6 +114,7 @@ embed_lyrics() { # args: source_dir, dest_dir # Places all MP3 files in a directory into folders based on the artist and album. +# Removes any problematic characters. # If you want to make changes in the current dir, run `mp3-tags-to-folders . .` organize_files() { [ $# -eq 2 ] || die "Arguments required: path to music directory, path to destination" @@ -123,13 +125,14 @@ organize_files() { mkdir -p _failed find "$src" -name '*.mp3' 2>/dev/null | \ while read -r i; do - artist="$(ffprobe -loglevel error -show_entries format_tags=album_artist -of default=noprint_wrappers=1:nokey=1 "$i" | tr -d ':' | tr '+!@#$%^&*:?"\\>' '_' | sed 's/\.\.*$//')" + artist="$(ffprobe -loglevel error -show_entries format_tags=album_artist -of default=noprint_wrappers=1:nokey=1 "$i" | tr -d ':' | tr '/+!@#$%^&*:?"\\>' '_' | sed 's/\.\.*$//' | perl -Mopen=locale -Mutf8 -pe 's/[\x{0300}-\x{036F}]//g')" [ -n "$artist" ] || { mv "$i" _failed/ && continue; } - album="$(ffprobe -loglevel error -show_entries format_tags=album -of default=noprint_wrappers=1:nokey=1 "$i" | tr -d ':' | tr '+!@#$%^&*:?>\\/"' '_' | sed 's/\.\.*$//')" + album="$(ffprobe -loglevel error -show_entries format_tags=album -of default=noprint_wrappers=1:nokey=1 "$i" | tr -d ':' | tr '+!@#$%^&*:?>\\/"' '_' | sed 's/\.\.*$//' | perl -Mopen=locale -Mutf8 -pe 's/[\x{0300}-\x{036F}]//g')" [ -n "$album" ] || { mv "$i" _failed/ && continue; } + fname="$(printf '%s' "${i##*/}" | perl -Mopen=locale -Mutf8 -pe 's/[\x{0300}-\x{036F}]//g')" mkdir -p "$artist/$album" - printf "%s -> %s\n" "$i" "$artist/$album" - mv "$i" "$artist/$album" + printf "%s -> %s\n" "$i" "$artist/$album/$fname" + mv "$i" "$artist/$album/$fname" done rmdir _failed 1>/dev/null 2>&1 || printf "Some tracks were not organised automatically, they are in ./_failed/" }