Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "Edit" files names
- X-seq: zsh-workers 41644
- From: Leah Neukirchen <leah@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: "Edit" files names
- Date: Wed, 06 Sep 2017 10:11:04 +0200
- In-reply-to: <87pob5ni6e.fsf__34694.9253035293$1504635253$gmane$org@wavexx.thregr.org> (Yuri D'Elia's message of "Tue, 05 Sep 2017 19:56:09 +0200")
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <87pob5ni6e.fsf__34694.9253035293$1504635253$gmane$org@wavexx.thregr.org>
Yuri D'Elia <wavexx@xxxxxxxxxx> 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@xxxxxxxx> http://leah.zone
Messages sorted by:
Reverse Date,
Date,
Thread,
Author