YellowJackets has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
My requirement is to copy a file into two different directories and rename them with the following.
1. filename.txt to be moved from inbox directory to archive directory and filename to be renamed to filename.<dateTime>.txt
I tried to do this by using use Time::Piece; and use File::Copy;
Got dateTime by using "my $toDate = localtime->strftime('%F %T');"
Got archive file name by using "my $archiveFileName = $newArchive."_".$toDate.".txt";"
but when I try to use copy to copy the file to archive directory it wont work.
I am using "copy ($filename, archive\\$archiveFileName);" in code.
2. filename.txt to be moved from inbox directory to out directory and filename to be renamed to filenameout.txt
I was able to do this by using rename.
Can anyone suggest how can we achieve this functionality.
Regards,
Raj
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: copy isn't working
by thanos1983 (Parson) on Mar 07, 2019 at 15:18 UTC | |
by YellowJackets (Initiate) on Mar 07, 2019 at 17:35 UTC | |
by poj (Abbot) on Mar 07, 2019 at 17:39 UTC | |
by YellowJackets (Initiate) on Mar 08, 2019 at 15:28 UTC | |
by poj (Abbot) on Mar 08, 2019 at 16:37 UTC | |
by BillKSmith (Monsignor) on Mar 08, 2019 at 16:06 UTC |