kiwi_bris_ct has asked for the wisdom of the Perl Monks concerning the following question:
my $yesterday = get_date (-1); print "Yesterday = $yesterday\n"; sub get_date { my $offset = shift || 0; my $ts = time + $offset*60*60*24; my ($day,$month,$year) = (localtime($ts))[3,4,5]; sprintf ("%02s%02s%04s",$day,$month+1,$year+1900); } rename "d:/EOD/20 January 2002/system.csv", "d:/EOD/20 January 2002/?? +???_system.csv"; rename "d:/EOD/20 January 2002/sales.csv", "d:/EOD/20 January 2002/??? +??_sales.csv"; my $source = "d:/EOD/20 January 2002/?????_system.csv"; my $source1 = "d:/EOD/20 January 2002/?????_sales.csv"; my $destination = "c:/New EOD/?????_system.csv"; my $destination1 = "c:/New EOD/?????_sales.csv"; open IN, $source or die "Can't read source file $source: $!\n"; + open IN, $source1 or die "Can't read source file $source1: $!\n"; + open OUT,">$destination" or die "Can't write on file $destination: $!\ +n"; open OUT,">$destination1" or die "Can't write on file $destination1: $ +!\n"; print 'Renamed csv files with date and copied to new directory'; while (<IN>) { print OUT $_; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Renaming file with date
by perlplexer (Hermit) on Apr 23, 2002 at 12:51 UTC | |
|
Re: Renaming file with date
by derby (Abbot) on Apr 23, 2002 at 12:25 UTC | |
by kiwi_bris_ct (Initiate) on Apr 24, 2002 at 06:34 UTC | |
|
Re: Renaming file with date (TMTOWT name files with date/time stamp)
by ybiC (Prior) on Apr 23, 2002 at 16:28 UTC |