Page 1 of 1

Copy Folders & Files - How To Do This

Posted: 11 Mar 2015 00:38
by Jer
I am trying to copy a directory and its sub-directories to the root of a USB drive, which is D:
Here is part of the batch file:

Code: Select all

@Echo Off
setlocal enableDelayedExpansion

CHDIR C:\
CHDIR "\Test Data"
XCOPY "This App" d: /E /I /Y


What I end up with is all the sub-directories and files in "This App" but not the folder "This App".
Files in "This App" get copied to the root of D:
Thanks.

Re: Copy Folders & Files - How To Do This

Posted: 11 Mar 2015 03:24
by Yury

Code: Select all

CHDIR /d "C:\Test Data"
XCOPY "This App" "D:\This App" /E /H /I /Y

Re: Copy Folders & Files - How To Do This

Posted: 11 Mar 2015 05:33
by Compo
Either

Code: Select all

XCopy "C:\Test Data\This App" "D:\This App" /EIHY
Or

Code: Select all

RoboCopy "C:\Test Data\This App" "D:\This App" /E /XJ

Re: Copy Folders & Files - How To Do This

Posted: 11 Mar 2015 10:24
by Jer
Thank you Yury for giving me a workable solution.

Compo, your shorter solution with XCOPY is what I will use.

I never knew robocopy existed. Another great option!
Jerry