mantra2006 has asked for the wisdom of the Perl Monks concerning the following question:
The filenames which start with ABC has to be renamed withABCTEST_062506.DAT XYZTEST_062506.DAT ABCTEST_062406.DAT XYZTEST_062506.DAT ABCTEST_062406.DAT XYZTEST_062506.DAT ABCTEST_062406.DAT XYZTEST_062506.DAT
sub scanDir() { $check ="ABCD" # this value will come from an array $base_dir = $_[0]; opendir(DIR, $base_dir) || die "Error: could not open input direct +ory $base_dir"; @current_dir = readdir(DIR); chomp(@current_dir); foreach $current_dirs (@current_dir) { $file_name = $current_dirs; $var = substr($file_name, 0, 3); $newvar = substr($file_name,3); if($var eq $check){ $newFileName = $check . $newvar; } } closedir(DIR); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: FileName Change
by davorg (Chancellor) on Aug 21, 2006 at 15:22 UTC | |
|
Re: FileName Change
by Fletch (Bishop) on Aug 21, 2006 at 15:21 UTC | |
|
Re: FileName Change
by un-chomp (Scribe) on Aug 21, 2006 at 16:31 UTC | |
| |
|
Re: FileName Change
by blazar (Canon) on Aug 21, 2006 at 17:03 UTC |