Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: renameing numbered files
- X-seq: zsh-users 10433
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: renameing numbered files
- Date: Sat, 24 Jun 2006 21:54:22 -0700
- In-reply-to: <20060625.052545.74742529.Meino.Cramer@xxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20060625.052545.74742529.Meino.Cramer@xxxxxx>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author