By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,359 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,359 IT Pros & Developers. It's quick & easy.

Recursively copy a directory tree

P: 9
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
Share this Question
Share on Google+
3 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
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
Expert 2.5K+
P: 4,059
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

P: 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.