473,569 Members | 2,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recursively copy a directory tree

9 New Member
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 13083
3,509 Recognized Expert Moderator Specialist
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. :-)


Jul 30 '07 #2
4,059 Recognized Expert Specialist
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
1 New Member
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");

Mar 6 '17 #4

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

Similar topics

by: Max M | last post by:
I guess that the best approach is calling a shell tool with something like os.popen(). But I cannot seem to find any free tools. Winzip has a command line option, but for registered users only. That is bothersome if I want to install the script on other machines. The same for pkwares zip. At least I cannot seem to find a free version of...
by: Antonio Lopez Arredondo | last post by:
hi all !!! I need to copy a folder and its subfolders to another location; which class should I use ? could only find the System.IO.Directory.MOVE but don't know how to COPY. thanks in advance, ant
by: melo | last post by:
Hello, I've been struggling with a function(s) to recursively set all folders and files to NOT read-only. So, I thought I'd post this message. What I need to do is: given a starting path, I need to recursively go through all files and folders below the starting path and check if the file or folder is read-only and, if so, set it to not...
by: Dan Nash | last post by:
Hi peeps.. Im using the TreeView control from IE COntrols to create a directory structure, and trying to do it recursively. The code works, but my question is simply how can I make the subdirs appear as leaves in the Tree, rather than as new branches? Here's the code..
by: graphicsxp | last post by:
Hi, I have the following records stored in the database : TableName: Folder { FolderID, FolderName, TopLevel} TableName: FolderRelationship { ParentID, ChildID} This describes a folder tree structure. Note that only one record has TopLevel set to 1, this is the top folder in the structure.
by: Scott Sauyet | last post by:
I found myself needing to find my way recursively through a document in XSLT, finding the dependencies one element had on others, and including only those in an initial set, their dependencies, the dependencies of those dependencies and so on. I managed to do it, but I'm not really happy with the method, and I'm wondering if anyone can...
by: smoothoperator12 | last post by:
Hi all, I have spent hours trying to figure out where I have went wrong with my code for my recursive function to list all the files in a directory, and all of the files in all of its subdirectories. This is the code:
by: pamela fluente | last post by:
What is the most current (for framework 2.0) and easy way to copy recursively all files from folder "Folder1" to folder "Folder2" ? Is there any simple function in the framework to do that? -P
by: kumarboston | last post by:
Hi all, I am trying to copy couple of directories and their files to another place. Each directory have 25-30 files and numbered accordingly, the problem I am facing is, I have to copy files numbered from 4-22 only and leave rest all. I have written a code but its only copying one directory and its files and not others. Overall...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.