Hi, I am trying to rename all files having _valid.csv to .csv as follows:
abc_valid1.csv to abc.csv
delta_valid1.csv to delta.csv
I though the following code might do the job:
use File::Copy;
my @list = <D:/CPPDaily/SOURCE/SOURCE/HMS/*_valid1.csv>;
foreach my $file(@list){
my $from = $_;
chomp $from;
(my $to = $from) =~ s/_valid1//g;
move($from, $to) or die(qq{failed to move $from -> $to});
}
But I am getting unexpected error message:
'Nov 4 08:00,/home/imanager/cppprod/del.csv' and 'Nov 4 08:00,/home/im
+anager/cppprod/del.csv' are identical (not copied) at Daily.txt line
+80.
Use of uninitialized value $atime in utime at c:/Perl/lib/File/Copy.pm
+ line 393, <FH> line 1.
Use of uninitialized value $mtime in utime at c:/Perl/lib/File/Copy.pm
+ line 393, <FH> line 1.
failed to move Nov 4 08:00,/home/imanager/cppprod/del.csv -> Nov 4 08:
+00,/home/imanager/cppprod/AR_LM.csv at Daily.txt line 80, <FH> line 1
+.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.