in reply to Not renaming/moving files
Typically, the old file does not exist, or the new file can not be created because permissions are not set properly.rename("$oldpath", "$newpath") or die "Error: $!";
Update: and try to chomp your $record.
use strict; use warnings; open my $fh, '<', "c:\\temp\\work.txt" or die "can not open file: $!"; while (my $record = <$fh>) { chomp $record; my $oldpath = "c:\\olddir\\$record"; my $newpath = "c:\\newdir\\$record"; rename $oldpath => $newpath or die "Error: $!"; } close $fh;
|
|---|