* Re: "Edit" files names
[not found] <87pob5ni6e.fsf__34694.9253035293$1504635253$gmane$org@wavexx.thregr.org>
@ 2017-09-06 8:11 ` Leah Neukirchen
0 siblings, 0 replies; only message in thread
From: Leah Neukirchen @ 2017-09-06 8:11 UTC (permalink / raw)
To: zsh-workers
Yuri D'Elia <wavexx@thregr.org> writes:
> Hi everyone,
>
> Let's assume I have a garbled file name that I want to rename more
> conveniently into an editor, without painful escaping.
>
> I'd like to do the following:
>
> $ editname *garbled*
>
> popping my $EDITOR with a file containing the original file name
> (unescaped), and upon saving+closing, renames the original into the new
> name provided. If the pattern expands to more files, it just repeats for
> each file, in turn.
>
> It's not hard to implement, but does anybody know of a tool which
> already does that (or something very similar)?
Not exactly what you asked for, but I like this (uses ZLE):
# imv -- interactive rename, using vared
imv() {
local src dst
for src; do
[[ -e $src ]] || { print -u2 "$src does not exist"; continue }
dst=$src
vared dst
[[ $src != $dst ]] && mkdir -p $dst:h && mv -n $src $dst &&
print -s mv -n $src:q:q $dst:q:q # save to history, thus M-. works
done
}
--
Leah Neukirchen <leah@vuxu.org> http://leah.zone
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-09-06 8:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <87pob5ni6e.fsf__34694.9253035293$1504635253$gmane$org@wavexx.thregr.org>
2017-09-06 8:11 ` "Edit" files names Leah Neukirchen
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).