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

Re: renaming with number prefix



Quoting Sven Guckes (guckes@xxxxxxxxxxxxxxxxx):
> Problem:
> Rename all files within a directory such that their names
> get a numeral prefix in the default sort order.
> 
> Btw, "leading zeroes" would be a bonus.
> 

i=1; for f in *; do echo mv $f $(echo $i| awk '{ printf("%03d", $0)}').$f; ((i++)); done

remove the first echo to really move files.
-- 
stephen@xxxxxxxxx



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