473,804 Members | 3,649 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 13128
numberwhun
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. :-)

Regards,

Jeff
Jul 30 '07 #2
KevinADC
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
mhalwi
1 New Member
@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_ba ckup");

thanks
mhalwi
Mar 6 '17 #4

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

Similar topics

7
2142
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 it. gzip seems able to do the trick, but I need to install Cygwin, that's
1
3360
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
2
10605
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 read-only. Any ideas?
10
2021
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..
2
2346
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.
8
2383
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 suggest something better. My technique involves manipulating a string containing the names, calling a...
9
19624
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:
9
5743
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
1
5682
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 /test1/step_1/prodinit_1....30 and I want to copy to /test2/step_1/prodinit_4...22 #!/bin/csh -f set dir1 =...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9569
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10558
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5503
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.