Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Jer
- Posts: 177
- Joined: 23 Nov 2014 17:13
- Location: California USA
#1
Post
by Jer » 11 Mar 2015 00:38
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.
-
Yury
- Posts: 115
- Joined: 28 Dec 2013 07:54
#2
Post
by Yury » 11 Mar 2015 03:24
Code: Select all
CHDIR /d "C:\Test Data"
XCOPY "This App" "D:\This App" /E /H /I /Y
-
Compo
- Posts: 599
- Joined: 21 Mar 2014 08:50
#3
Post
by Compo » 11 Mar 2015 05:33
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
-
Jer
- Posts: 177
- Joined: 23 Nov 2014 17:13
- Location: California USA
#4
Post
by Jer » 11 Mar 2015 10:24
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