script/batch file to copy some selected folders using robocoy or xcopy

Sumesh BNR
Sumesh BNR used Ask the Experts™
on
I am looking for a script/batch file  to copy some selected folders using robocoy or xcopy my source folder structure ; the main folder is CODE under the CODE folder there are sub folders as 01 ,02 and so on around 500 folders.I want to copy some specific folders say 2010_10_21 and 2010_10_22 from  inside each subfolders to a destination directory called \\myserver\CODE_2010_10 with the source folder structure each subfolder have folders nmed other dates so the scrip t need to select the two dated folders only .please help.


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
why not use a different program like total commander?

Just google it, this will give you what you need in GUI format.
TechnoChatWintel Administrator / Cloud Computing

Commented:
Use following command for xcopy.

xcopy /e /h /r /y "SourceFolder" "DestinationFolder"

Thanks
Saugata
No I need a script
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

TechnoChatWintel Administrator / Cloud Computing

Commented:
Try this..

Thanks
Saugata
@echo off
set source=Type here your full source path
set destination=Type here your full destination path
xcopy /e /h /r /y "%source%" "%desstination%"

Open in new window

how to loop for 500 sub-folders 01,02,03 and so on?
IT / Software Engineering Consultant
Top Expert 2016
Commented:
I think this should get the job done.

~bp
@echo off
set BaseDir=c:\code
set DestDir=\\myserver
for /F "tokens=*" %%A in ('dir /s /ad /b "%BaseDir%\*" ^| findstr /c:"2010_10_21" /c:"2010_10_22"') do (
  xcopy /E /H /R /Y "%%~A" "%DestDir%\code_%%~nA"
)

Open in new window

Good job
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
Glad that helped, thanks.

~bp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial