Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: renaming with number prefix



Bart Schaefer stands accused of saying:
> On Jan 23,  4:54pm, Sven Guckes wrote:
> } Subject: renaming with number prefix
> }
> } 	$ ls
> } 	abc bar baz foo zyxxy
> } 	$ <command>
> } 	$ ls
> } 	1.abc 2.bar 3.baz 4.foo 5.zyxxy
> } 
> } So - what's that <command>?
> 
>     integer i=0; for f in *; do mv $f $[i+=1].$f; done
> 
> } Btw, "leading zeroes" would be a bonus.
> 
> How many leading zeros?  I'm guessing 3 digits total would be OK:
> 
>     typeset -Z 3 i=1 ; for f in *; do echo $f $i.$f; ((++i)); done
> 
> Too bad $[i+=1] doesn't respect the typeset flags of `i' when printing.

typeset -Z 3 i=1 ; for f in *; do echo $f $i.$f; typeset -Z 3 i=$((++i)); done

---------------------------------------------------------------------------
Danny Dulai                                           Feet. Pumice. Lotion.
http://www.ishiboo.com/~nirva/                            nirva@xxxxxxxxxxx
---------------------------------------------------------------------------



Messages sorted by: Reverse Date, Date, Thread, Author