gmo has asked for the wisdom of the Perl Monks concerning the following question:
### #Use the unix ls command to list the jpg files in the subdirectory ### use Shell(ls); @array = ls *jpg ; ### #Set the TotFiles scalar to the value number of elements in @array ### $TotFiles = @array + 1; print "Value of TotFiles is: $TotFiles \n"; ## #create four digit padding for the frames with a for loop ## for( $loop = 0; $loop <= $TotFiles; $loop++ ) { if ($loop < 10) { $padder = '000'; } if (($loop > 10) && ($loop < '100')){ $padder = '00'; } if (($loop > 100) && ($loop < 1000)) { $padder = '0'; } if ($loop > 1000) { $padder = ''; } ## #create a new name using the padder and the loop number ## $new = "snowscene"."."."$padder"."$loop".".jpg"; print "$new \n"; $old = @array[[$loop]] ; print $old; rename ($old, $new) ; }
holli fixed formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: renaming a list of files
by Zaxo (Archbishop) on Aug 17, 2005 at 06:44 UTC | |
|
Re: renaming a list of files
by graff (Chancellor) on Aug 17, 2005 at 08:09 UTC | |
|
Re: renaming a list of files
by japhy (Canon) on Aug 17, 2005 at 15:21 UTC | |
|
Re: renaming a list of files
by QM (Parson) on Aug 17, 2005 at 18:23 UTC | |
by parv (Parson) on Aug 18, 2005 at 18:44 UTC |