in reply to Re: copy isn't working
in thread copy isn't working
Update 1: I am using WindowsOS. \\ worked for rename so using the same for copy as well.
Update 2: I did try with or die "Copy failed: $!" but returned "Copy failed: at c:\perl_scripts\copy_rename.pl line 33."
Update 3: I want to archive the file in a different directory with timestamp after processing it. Hope that helps
Code :
use strict; use warnings; use Time::Piece; use File::Copy; my $toDate = localtime->strftime('%F %T'); foreach my $file (glob "C:\\data\\app\\AppSpecific1\\In\\test*") { my $archiveFileName = $file."_".$toDate.".txt"; print "copy $file, $archiveFileName\n"; copy ($file, "C:\\data\\app\\AppSpecific1\\Archive\\".$archiveFile +Name) or die "Copy failed: $!"; }
Compilation error perl c:\perl_scripts\copy_rename.pl copy C:\data\app\AppSpecific1\In\test.txt, C:\data\app\AppSpecific1\In\test.txt_2019-03-07 12:22:44.txt Copy failed: at c:\perl_scripts\copy_rename.pl line 33.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: copy isn't working
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 |