ranciid has asked for the wisdom of the Perl Monks concerning the following question:
I need help with this snippet of code :
my ($oldpath, $newpath, $line); open (WORKFILE, "c:\\temp\\work.txt"); while ($record = <WORKFILE>) { $oldpath = "c:\\olddir\\$record"; $newpath = "c:\\newdir\\$record"; rename("$oldpath", "$newpath"); } close(WORKFILE);
Basically, it is reading a text file containing lines of file names. As I read the list, I would like to move them to another directory but somehow, it doesn't seem to be working.
If I replace the "rename" with "print", the correct "oldpath" & "newpath" is displayed, which means that the variables have been correctly assigned and the path & file names are correct. But it just doesn't rename/move.
Am I doing something wrong?
Thanks !
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Not renaming/moving files
by toolic (Bishop) on Jan 27, 2010 at 01:05 UTC | |
|
Re: Not renaming/moving files
by Anonymous Monk on Jan 27, 2010 at 01:12 UTC | |
by jethro (Monsignor) on Jan 27, 2010 at 04:07 UTC | |
|
Re: Not renaming/moving files
by ranciid (Novice) on Jan 28, 2010 at 07:57 UTC |