zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: renameing numbered files
Date: Sat, 24 Jun 2006 21:54:22 -0700	[thread overview]
Message-ID: <060624215422.ZM7997@torch.brasslantern.com> (raw)
In-Reply-To: <20060625.052545.74742529.Meino.Cramer@gmx.de>

On Jun 25,  5:25am, Meino Christian Cramer wrote:
} 
}  How can I do this in a most zshy way?

autoload -U zmv
zmv -Qf 'Example(<->).txt(On)' 'Example${(l:4::0:)$(($1+10))}.txt'

That probably deserves some explanation:

Either the -Q option or (#qOn) is required because zmv turns off "bare"
glob qualifiers by default.

The -f option is required because the set of source names overlaps with
the set of destination names (0102 is in both).

Sorting (On) forces the higher-numbered files to be renamed first,
otherwise 0092 --> 0102 --> 0112 will result (the original 0102 would
be lost).  If the leading zeroes weren't there, you'd need (nOn) for
numeric sorting.

Using $(($1+10)) discards leading zeroes, so (l:4::0:) puts them back.

I suggest playing around with "zmv -n" a bit to be sure it's going to
do what you intended.


  reply	other threads:[~2006-06-25  4:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-25  3:25 Meino Christian Cramer
2006-06-25  4:54 ` Bart Schaefer [this message]
2006-06-25  5:12   ` Meino Christian Cramer

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=060624215422.ZM7997@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /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).