mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-01-30 09:48:11 +01:00
Merge b157d54410b152095f6475e8df3fcdb16207aad8 into 07952026753f1bbeaf5b6c4eb5414a9c51536041
This commit is contained in:
commit
9b5047e3a8
@ -110,24 +110,32 @@ cmd copyto ${{
|
|||||||
cmd setbg "$1"
|
cmd setbg "$1"
|
||||||
|
|
||||||
cmd bulkrename ${{
|
cmd bulkrename ${{
|
||||||
tmpfile_old="$(mktemp)"
|
tmpfile_old="$(mktemp)"
|
||||||
tmpfile_new="$(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"
|
for f in $fs; do
|
||||||
echo "$fs" > "$tmpfile_new"
|
echo "${f%.*}" >> "$tmpfile_old"
|
||||||
$EDITOR "$tmpfile_new"
|
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
|
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new" "$tmpfile_ext"; exit 1; }
|
||||||
do
|
|
||||||
[ "$src" = "$dst" ] || [ -e "$dst" ] || mv -- "$src" "$dst"
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -f "$tmpfile_old" "$tmpfile_new"
|
exec 3<"$tmpfile_old"
|
||||||
lf -remote "send $id unselect"
|
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
|
# Bindings
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user