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

Re: renaming with number prefix



>>>>> "Sven" == Sven Guckes <guckes@xxxxxxxxxxxxxxxxx> writes:

    Sven> Problem:
    Sven> Rename all files within a directory such that their names
    Sven> get a numeral prefix in the default sort order.

    Sven> Example:

    Sven> 	$ ls
    Sven> 	abc bar baz foo zyxxy
    Sven> 	$ <command>
    Sven> 	$ ls
    Sven> 	1.abc 2.bar 3.baz 4.foo 5.zyxxy

    Sven> So - what's that <command>?

perl -e 'map rename($_, ++$i.".".$_), @ARGV' *

    Sven> Btw, "leading zeroes" would be a bonus.

perl -e 'map rename($_, sprintf "%03d.%s",++$i,$_), @ARGV' *

Ulrich Pfeifer
--
OK, I could change the source, but I'd rather not, besides looking
    at it makes my head hurt
        --Richard Caley speaking about the freeWAIS-sf sources



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