skyler has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I'm not an expert in Perl but I'm trying very hard to be one. I'm writing this code to copy "*.rtf" files to another directory. I grap these files with an array and then I tried to copy them to C:\Temp but I don't have any success. This is what I have so far.... I'll appreciate your help.
#! perl -w use strict; use File::Find; use File::Copy; my $line = 'C:\08\00004DC4.013'; opendir MYDIR, $line or die "Could not opendir $line: $!\n"; my @allfiles = grep { $_ ne '.' and $_ ne '..' } readdir MYDIR ; my @files = grep { !-d } @allfiles ; my @dirs = grep { -d } @allfiles ; my @select_files = join($/, grep( /\.rtf$/, @allfiles )); closedir(MYDIR); copy("$File::Find::name","C:\\temp\\/$_"); print "Current directory contains " . @files . " files and " . @dirs . " directories.\n" ; print join("\n", @allfiles);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: copy files to another directory
by steves (Curate) on Feb 19, 2003 at 06:48 UTC | |
by Anonymous Monk on Feb 19, 2003 at 15:08 UTC | |
Re: copy files to another directory
by Aristotle (Chancellor) on Feb 19, 2003 at 06:49 UTC | |
by fruiture (Curate) on Feb 19, 2003 at 13:46 UTC | |
by Aristotle (Chancellor) on Feb 19, 2003 at 14:34 UTC | |
Re: copy files to another directory
by martymart (Deacon) on Feb 19, 2003 at 10:19 UTC | |
by jasonk (Parson) on Feb 19, 2003 at 14:19 UTC |
Back to
Seekers of Perl Wisdom