uksza has asked for the wisdom of the Perl Monks concerning the following question:
Maybe any oneliner?#!/usr/bin/perl $dir = "/home/my/files" ; chdir $dir or die "$!"; opendir(DIR,$dir ) or die "$!"; $i = 1; @files = grep { !/^\./ } readdir(DIR); foreach (@files) { $new = $_; $new =~ s/$new/sprintf ("%03d-%s",$i,$_)/e; rename $_,$new; $i++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Rename FILE to nnn-FILE
by BrowserUk (Patriarch) on Dec 30, 2004 at 03:01 UTC | |
|
Re: Rename FILE to nnn-FILE
by gaal (Parson) on Dec 29, 2004 at 22:52 UTC | |
by uksza (Canon) on Dec 29, 2004 at 23:03 UTC | |
by gaal (Parson) on Dec 30, 2004 at 06:45 UTC | |
|
Re: Rename FILE to nnn-FILE
by Eimi Metamorphoumai (Deacon) on Dec 29, 2004 at 23:02 UTC | |
by uksza (Canon) on Dec 29, 2004 at 23:10 UTC | |
|
Re: Rename FILE to nnn-FILE
by saskaqueer (Friar) on Dec 30, 2004 at 07:02 UTC |