Lately I find myself using File::Find more and more often...

Here this schould help you...

#Used to recurse through directories and files use File::Find; #Used to copy directory strucutre of "USERS" use File::Path; #Used to copy each file to its directory use File::Copy; #No trailing slash on any of the following #Specify directory to copy $old_dir = '/site/users'; #Specify directory to backup to $new_dir = '/backup/users'; print "Copy Directory structure of $old_dir - "; mkpath([$old_dir, $new_dir], 1, 0777) || die "\n\tCouldn't copy $old_d +ir '$!'"; print "Successful\n"; print "Copying files to new directory -\n"; find(\&each_file,"$old_dir/") || die "\n\tCouldn't copy files '$!'"; print "Succssful\n"; sub each_file{ my $FilePath = $File::Find::name; #Specified comlete location to fi +le #Location to move to my $MovePath = $FilePath; $MovePath=~s/\Q$old_dir\E/\Q$new_dir\E/i; #Do this so it doesn't in +terpret "dir" vairables as regexp print "Copying file $_ - "; copy($FilePath,$MovePath); print "Successful\n"; }

"The pajamas do not like to eat large carnivore toasters."
In German: "Die Pyjamas mögen nicht große Tiertoaster essen.
In Spanish: "Los pijamas no tienen gusto de comer las tostadoras grandes del carnívoro."


In reply to Re: How do I emulate DOS XCOPY command under Perl for Windows by thealienz1
in thread How do I emulate DOS XCOPY command under Perl for Windows by raymac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.