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

Re: renaming with number prefix



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.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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