bin: adjust playlist update function

This commit is contained in:
xeruf 2021-10-12 13:55:22 +02:00
parent afbf7040a8
commit 6384cf62f1
2 changed files with 4 additions and 3 deletions

View File

@ -2,8 +2,8 @@
# Creates the last arg as directory (or its parent if not ending in a slash) # Creates the last arg as directory (or its parent if not ending in a slash)
# and moves the preceding arguments into it. # and moves the preceding arguments into it.
# Automatically elevates if missing permissions. # Automatically elevates if missing permissions.
for last; do true; done last=${@:$#}
! test -e "$1" && echo "$1 does not exist" && exit 1 ! test -e "$1" && echo "$1 does not exist" && exit 1
checkaccess -w "$@" || elevate=sudo checkaccess -w "$@" || elevate=sudo
$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac) $elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)
$elevate mv -n "$@" $elevate mv --interactive "$@"

View File

@ -9,7 +9,8 @@ case $command in
highlight $pl highlight $pl
cat $pl | rev | cut -d'/' -f-2 | rev | while read f; do cat $pl | rev | cut -d'/' -f-2 | rev | while read f; do
test -n "$f" || continue 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 | tee $pl
done;; done;;
(edit) ${EDITOR:-nano} $(find $MUSIC/Playlists -iname "$1\.*" | grep . || find $MUSIC/Playlists -iname "$1*");; (edit) ${EDITOR:-nano} $(find $MUSIC/Playlists -iname "$1\.*" | grep . || find $MUSIC/Playlists -iname "$1*");;