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
@ -112,21 +112,29 @@ 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"
|
||||||
|
|
||||||
[ "$(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
|
done
|
||||||
|
|
||||||
rm -f "$tmpfile_old" "$tmpfile_new"
|
cp "$tmpfile_old" "$tmpfile_new"
|
||||||
|
$EDITOR "$tmpfile_new"
|
||||||
|
|
||||||
|
[ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new" "$tmpfile_ext"; exit 1; }
|
||||||
|
|
||||||
|
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"
|
lf -remote "send $id unselect"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user