473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Batch Script To Copy A Subfolder To Another Directory

I need to copy folder and its contents to target folder Using Batch Scripting.
For Example , we have folder named "ParentFolder" and inside this folder we have "Child1" "Child2" folders and inside this i have a text file.
Target folder is named as "Targetfolder"
I want to 1st check if the subfolder of "Parentfolder" has "Child1" folder in it and then copy this folder "Child1" and its contents to "Targetfolder"
this is what i have done so far but i am getting both child1 and child2 folder .

Expand|Select|Wrap|Line Numbers
  1. @echo on
  2. set FOLDER1=c:\Temp\FOLDER1
  3. set FOLDER2=c:\Temp\FOLDER2
  4. if exist %FOLDER1% ( xcopy /Q /D /S /V %FOLDER1% %FOLDER2% )
  5. :END
Dec 6 '12 #1
5 3585
Rabbit
12,516 Expert Mod 8TB
I see no references in your script to these Child1, Child2, and TargetFolder folders that you refer to in your description of the problem.
Dec 6 '12 #2
zmbd
5,501 Expert Mod 4TB
You might want to look at a primer for batch files A Windows Batch File Programming Primer

Also, "%FOLDER1%" is not set.
Dec 6 '12 #3
I will have to search folder1 to find id child1 exists ,and if it exist i ve to copt chils folder including its contents into another folder.

i am new to batch scripting pls help
Dec 7 '12 #4
Sry, adding more detail

FOLDER1 is parent folder
and folder2 is target folder
Dec 7 '12 #5
zmbd
5,501 Expert Mod 4TB
I gave you the link to the tutorial, it has everything you need to solve the problem.

BYTES is not a code writing nor homework service. Rabbit and my self have pointed out several errors that you need to fix and have given you a tool/reference.

If you will rework and repost your efforts someone here may provide "Information, Clarification, and/or Correction"
Dec 7 '12 #6

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

Similar topics

3
by: John McGinty | last post by:
simple as that really. I want to run a batch script when a button in pressed. The script is to run a DTS package (thats another issue entirely) to refresh some data which is all working just fine....
5
by: Frank | last post by:
I'm using VB .NET and I'm finding that CopyTo will not help me copy all the files in one directory to antoher directory at one time. Which command (if that's the word) do I use to copy ALL the...
0
by: py | last post by:
I am trying to execute a batch script on a remote computer. The batch script looks like: @echo off start c:\python24\python.exe c:\a_script.py Here's the setup: Computer A (my computer),...
1
by: jschmidt | last post by:
I am wondering if there is a way to zip a (one) file using a batch script. I have an access database that needs to be zipped on a regular basis because many people download this file from a website. ...
7
by: SmartPHP | last post by:
Dear friends i want to copy the images from one directory on server and paste them into another directory on my local computer....can someone tell me how can do that..it'll be a great help for...
1
by: Rajeswary | last post by:
I need to copy an excel doc in the same directory with a new name.. That is I have got an excel file abd_Week 37 and I need to run a batch script to copy the same file to the same directory with...
5
by: veeraiah | last post by:
Hi, I am new to PERL Scripting, i need your help with one of the problem i am having. I am having a PERL Script which has two variables $CurMon and $PriorMon. a Windows batch script calls this...
3
by: David V | last post by:
I'm having trouble copying DLLs from a folder in my project to the project's output directory. I have copied seven SQL CE DLLs (the SqlCe*.dll set) to a Libs folder in my project. The DLLs VS...
2
by: foss | last post by:
hi all, I am not able to copy file from a directory in the server to another directory. Here, the source is outside the web root directory and the destination is inside the web root directory. ...
2
by: AnitaB | last post by:
I have to create a perl script, which is calling a .sql script. This .sql script is creating alphabetic listing of .inc files from A-Z. All the .inc files will be having a suffix with lowercase of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.