mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-01-30 09:48:11 +01:00
Merge b157d54410b152095f6475e8df3fcdb16207aad8 into 7a96fb100cf385e05c211937b509d2bf166299e6
This commit is contained in:
commit
a8dd63becf
@ -110,24 +110,32 @@ cmd copyto ${{
|
||||
cmd setbg "$1"
|
||||
|
||||
cmd bulkrename ${{
|
||||
tmpfile_old="$(mktemp)"
|
||||
tmpfile_new="$(mktemp)"
|
||||
tmpfile_old="$(mktemp)"
|
||||
tmpfile_new="$(mktemp)"
|
||||
tmpfile_ext="$(mktemp)"
|
||||
|
||||
[ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls)
|
||||
[ -n "$fs" ] && fs=$(basename -a $fs | sort -fV) || fs=$(find . -maxdepth 1 -type f | cut -c 3- | sort -fV)
|
||||
|
||||
echo "$fs" > "$tmpfile_old"
|
||||
echo "$fs" > "$tmpfile_new"
|
||||
$EDITOR "$tmpfile_new"
|
||||
for f in $fs; do
|
||||
echo "${f%.*}" >> "$tmpfile_old"
|
||||
echo "${f##*.}" >> "$tmpfile_ext"
|
||||
done
|
||||
|
||||
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new"; exit 1; }
|
||||
cp "$tmpfile_old" "$tmpfile_new"
|
||||
$EDITOR "$tmpfile_new"
|
||||
|
||||
paste "$tmpfile_old" "$tmpfile_new" | while IFS="$(printf '\t')" read -r src dst
|
||||
do
|
||||
[ "$src" = "$dst" ] || [ -e "$dst" ] || mv -- "$src" "$dst"
|
||||
done
|
||||
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new" "$tmpfile_ext"; exit 1; }
|
||||
|
||||
rm -f "$tmpfile_old" "$tmpfile_new"
|
||||
lf -remote "send $id unselect"
|
||||
exec 3<"$tmpfile_old"
|
||||
exec 4<"$tmpfile_ext"
|
||||
exec 5<"$tmpfile_new"
|
||||
|
||||
while IFS= read -r old_name <&3 && IFS= read -r ext <&4 && IFS= read -r new_name <&5; do
|
||||
[ "$old_name" = "$new_name" ] || [ -e "$new_name.$ext" ] || mv -- "$old_name.$ext" "$new_name.$ext"
|
||||
done
|
||||
|
||||
rm -f "$tmpfile_old" "$tmpfile_new" "$tmpfile_ext"
|
||||
lf -remote "send $id unselect"
|
||||
}}
|
||||
|
||||
# Bindings
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user