From 6384cf62f126c687e5743a0a0354b5f75cb6718b Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 12 Oct 2021 13:55:22 +0200 Subject: [PATCH] bin: adjust playlist update function --- .local/bin/scripts/m | 4 ++-- .local/bin/scripts/pl | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.local/bin/scripts/m b/.local/bin/scripts/m index 2818794..b039df2 100755 --- a/.local/bin/scripts/m +++ b/.local/bin/scripts/m @@ -2,8 +2,8 @@ # Creates the last arg as directory (or its parent if not ending in a slash) # and moves the preceding arguments into it. # Automatically elevates if missing permissions. -for last; do true; done +last=${@:$#} ! test -e "$1" && echo "$1 does not exist" && exit 1 checkaccess -w "$@" || elevate=sudo $elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac) -$elevate mv -n "$@" +$elevate mv --interactive "$@" diff --git a/.local/bin/scripts/pl b/.local/bin/scripts/pl index 7168f6e..383b441 100755 --- a/.local/bin/scripts/pl +++ b/.local/bin/scripts/pl @@ -9,7 +9,8 @@ case $command in highlight $pl cat $pl | rev | cut -d'/' -f-2 | rev | while read f; do test -n "$f" || continue - find -path "*${f#../}" -prune | grep --color=never . || find -path "*${f##* - }" -o -path "*${f##*/}" | head -1 | grep --color=never . || echo $f + newpath="$(find $MUSIC -path "*${f#*../}" -prune | grep . || find $MUSIC -path "*${f##* - }" -o -path "*${f##*/}" | grep -m 1 .)" + test -n "$newpath" && realpath --relative-to $(dirname "$pl") "$newpath" || echo "$f" done | tee $pl done;; (edit) ${EDITOR:-nano} $(find $MUSIC/Playlists -iname "$1\.*" | grep . || find $MUSIC/Playlists -iname "$1*");;