Quickie 1-liners are also possible in Perl, and it's a lot more
flexible than awk to boot:
perl -e 'for(<*>) {rename $_,$1.($2-720).$3 if /(.+?)(\d+)(.img)$/}'
This (as well as I suspect some of the shell scripts posted) would
fail if you had asked to rename to the range 001..360 since the
leading zeroes will not appear. This can be fixed by a bit of
defensive programming: replace '($2-720)' with
'sprintf("%03d",$2-720)'.
-- Ian
On Fri, Dec 10, 2010 at 1:51 AM, wu donghui <[log in to unmask]> wrote:
> Dear all,
> I need a script to renumber my image. My initial image number ranges from
> *_1081.img to *_1440.img. There are 360 images in total. I want to renumber
> these images with the ranges from *_361.img to *_720.img, that means every
> initial image-720, but I don't know how to do it. Below is my script draft.
>
>
> #! /bin/csh -f
> @ i = 1081
> while ( $i >= 1081 )
> while ($i <= 1440 )
> echo mv CD267A_3_pk_1_$i.img CD267A_3_pk_1_$i-720.img
> @ i++
> end
> exit
>
>
> Can anyone help me for this script? Thank you very much.
>
> Best regards,
> Donghui
|