mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
Make it more efficient
This commit is contained in:
parent
4cd9c62c93
commit
13714818d4
@ -95,22 +95,23 @@ cmd copyto ${{
|
|||||||
cmd setbg "$1"
|
cmd setbg "$1"
|
||||||
|
|
||||||
cmd bulkrename ${{
|
cmd bulkrename ${{
|
||||||
old="$(mktemp)"
|
tmpfile_old="$(mktemp)"
|
||||||
new="$(mktemp)"
|
tmpfile_new="$(mktemp)"
|
||||||
[ -z "$fs" ] && fs="$(ls)"
|
|
||||||
printf '%s\n' "$fs" >"$old"
|
[ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls)
|
||||||
printf '%s\n' "$fs" >"$new"
|
|
||||||
$EDITOR "$new"
|
echo "$fs" > "$tmpfile_old"
|
||||||
[ "$(wc -l < "$new")" -ne "$(wc -l < "$old")" ] && exit
|
echo "$fs" > "$tmpfile_new"
|
||||||
paste "$old" "$new" | while IFS= read -r names; do
|
$EDITOR "$tmpfile_new"
|
||||||
src="$(printf '%s' "$names" | cut -f1)"
|
|
||||||
dst="$(printf '%s' "$names" | cut -f2)"
|
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new"; exit 1; }
|
||||||
if [ "$src" = "$dst" ] || [ -e "$dst" ]; then
|
|
||||||
continue
|
paste "$tmpfile_old" "$tmpfile_new" | while IFS="$(printf '\t')" read -r src dst
|
||||||
fi
|
do
|
||||||
mv -- "$src" "$dst"
|
[ "$src" = "$dst" ] || [ -e "$dst" ] || mv -- "$src" "$dst"
|
||||||
done
|
done
|
||||||
rm -- "$old" "$new"
|
|
||||||
|
rm -f "$tmpfile_old" "$tmpfile_new"
|
||||||
lf -remote "send $id unselect"
|
lf -remote "send $id unselect"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user