469,362 Members | 2,421 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

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
Jul 30 '07 #1
3 11655
numberwhun
3,503 Expert Mod 2GB
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::Recursive. 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
Jul 30 '07 #2
KevinADC
4,059 Expert 2GB
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.
Jul 30 '07 #3
mhalwi
1
@KevinADC
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_backup");

thanks
mhalwi
Mar 6 '17 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Antonio Lopez Arredondo | last post: by
10 posts views Thread by Dan Nash | last post: by
2 posts views Thread by graphicsxp | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.