in reply to Shorter/Better way to rename list of files in a directory
Hello Everyone,
I am trying a similar code in my windows environment, the files are not getting renamed.
$var = 0; $UserInputDir = "<mydir>"; opendir DH, $UserInputDir or die "Cannot open $UserInputDir: $!"; @files = readdir DH; foreach $file (@files) { next if $file=~/^\./; $OldFileName = $file; $file =~ s/.*.Log/ObjMgr_enu_$var.Log/; $var = $var + 1; rename ($OldFileName,$file); } closedir DH;
Not sure if something needs to be changed for windows.
Thanks Xhings
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Shorter/Better way to rename list of files in a directory
by Anonymous Monk on Apr 08, 2012 at 08:00 UTC | |
by Corion (Patriarch) on Apr 08, 2012 at 08:56 UTC |