#!/usr/bin/perl -w use strict; my $dir = "/home/my/files"; chdir $dir or die "can't chdir $dir: $!"; my $i; do { rename $_, ++$i . "-$_" or die "can't rename: $!" } for glob "*";
Will break on directories with more than 999 files. But so will your original. :)
(This is not meant to be golf, by the way. "I'm not saying I'd code it this way, but I'm not saying I wouldn't", to paraphrase $SOMEONE_SMARTER_THAN_ME (whose identity I forget.))
In reply to Re: Rename FILE to nnn-FILE
by gaal
in thread Rename FILE to nnn-FILE
by uksza
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |