Recursively copy a directory tree

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gemstone
    New Member
    • Jul 2007
    • 9

    Recursively copy a directory tree

    hi guys,
    i wanna copy a directory with all its sub directories, to another directory.
    pls help. its urgent. i even tried xcopy, but in vain
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    We would be more than happy to help, but we need to know what you have tried thus far so that we can guide you in the right direction. Please post the code you have tried and we can then give you a nudge here or there.

    Have you searched CPAN to see what modules you might use for this task? Heck, if you just put the words "copy recursive" into the search box, one of the first couple of results is File::Copy::Rec ursive. I am sure that if you take a read on that, you will be able to figure out how to do what you want.

    Also, I understand that this is an urgent matter for you (a lot of people post that phrase), but please remember that it isn't for us and we are here to help you learn. :-)

    Regards,

    Jeff

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Personally, if it were me, and if the script does not need to be portable, I would shell out to the operating system and use whatever command your operating system has in place. Assuming windows, go to the DOS prompt and type:

      xcopy /?

      and read the various command options that are available.

      In your perl script:

      system("xcopy [options]");

      I totally agree with Jeff too, next time post the code you have tried and no questions are urgent, they all have the same priority: none.

      Comment

      • mhalwi
        New Member
        • Mar 2017
        • 1

        #4
        Originally posted by KevinADC
        Personally, if it were me, and if the script does not need to be portable, I would shell out to the operating system and use whatever command your operating system has in place. Assuming windows, go to the DOS prompt and type:

        xcopy /?

        and read the various command options that are available.

        In your perl script:

        system("xcopy [options]");

        I totally agree with Jeff too, next time post the code you have tried and no questions are urgent, they all have the same priority: none.
        Hi Kevin,

        do you know how to make sure that the xcopy command to make it is working to backup the folder which is in the parent folder only. i tried the code below but it is not working when i put the script on the same layer as the parent folder. please help.


        system ("xcopy /E /I /G /H prod\\idrive prod\\idrive_ba ckup");

        thanks
        mhalwi

        Comment

        Working...