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 bulkrename ${{
|
||||
old="$(mktemp)"
|
||||
new="$(mktemp)"
|
||||
[ -z "$fs" ] && fs="$(ls)"
|
||||
printf '%s\n' "$fs" >"$old"
|
||||
printf '%s\n' "$fs" >"$new"
|
||||
$EDITOR "$new"
|
||||
[ "$(wc -l < "$new")" -ne "$(wc -l < "$old")" ] && exit
|
||||
paste "$old" "$new" | while IFS= read -r names; do
|
||||
src="$(printf '%s' "$names" | cut -f1)"
|
||||
dst="$(printf '%s' "$names" | cut -f2)"
|
||||
if [ "$src" = "$dst" ] || [ -e "$dst" ]; then
|
||||
continue
|
||||
fi
|
||||
mv -- "$src" "$dst"
|
||||
tmpfile_old="$(mktemp)"
|
||||
tmpfile_new="$(mktemp)"
|
||||
|
||||
[ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls)
|
||||
|
||||
echo "$fs" > "$tmpfile_old"
|
||||
echo "$fs" > "$tmpfile_new"
|
||||
$EDITOR "$tmpfile_new"
|
||||
|
||||
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new"; exit 1; }
|
||||
|
||||
paste "$tmpfile_old" "$tmpfile_new" | while IFS="$(printf '\t')" read -r src dst
|
||||
do
|
||||
[ "$src" = "$dst" ] || [ -e "$dst" ] || mv -- "$src" "$dst"
|
||||
done
|
||||
rm -- "$old" "$new"
|
||||
|
||||
rm -f "$tmpfile_old" "$tmpfile_new"
|
||||
lf -remote "send $id unselect"
|
||||
}}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user