From: Leah Neukirchen <leah@vuxu.org>
To: zsh-workers@zsh.org
Subject: Re: "Edit" files names
Date: Wed, 06 Sep 2017 10:11:04 +0200 [thread overview]
Message-ID: <87o9qo2qnb.fsf@gmail.com> (raw)
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")
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
parent reply other threads:[~2017-09-06 8:11 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <87pob5ni6e.fsf__34694.9253035293$1504635253$gmane$org@wavexx.thregr.org>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o9qo2qnb.fsf@gmail.com \
--to=leah@vuxu.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).