What started as me accidentally forgetting an sprintf turned into a fixer utility. If this doesn't already exist, somebody out there might find it useful...
$ ~/bin/nrename nrename [opts] <directory> OPTIONS: --dry-run -n Dry-run, just show what it would've done --verbose -v Shows renames as they happen DESCRIPTION: Renames all necessary files in a directory with respect to numbers in their filenames such that when they sort alphabetically later, their alphabetic order is the same as their numeric order. Essentially it just zero-pads numbers within filenames where needed, but it can deal with any number of digits anywhere in the filename. For instance, these files: 20_foo_5.dat 20_foo_20.dat 5_foo_6.dat Would normally sort: 20_foo_20.dat 20_foo_5.dat 5_foo_6.dat Which is entirely wrong. What nrename will do is: 05_foo_06.dat 20_foo_05.dat 20_foo_20.dat Which is what you presumably wanted. AUTHOR: Brad Fitzpatrick <firstname.lastname@example.org>