Greg
Greg

Reputation: 141

Windows cmd batch file, copy source folder and contents

I'm using XCOPY to copy a deployment package filled with files. I can get them all to copy but I'd like them to retain in the folders. For example, I have: C:\Utilities which has file1, file2, & file3. I use:
XCOPY "C:\Utilities\" D:\destination /s /i /w
and it copies file1, file2, & file3 no problem but I'd like it to copy the "Utilities" folder with the files inside. I searched for this but all answers I found are for copying only the contents of a source folder, not the source folder itself. Your help is appreciated. Thanks!

Upvotes: 2

Views: 2293

Answers (2)

Splash
Splash

Reputation: 126

xcopy /E /I C:\Utilities D:\destination\Utilities

Update: Windows has a built-in manual for console commands. Try this:

xcopy /?

Upvotes: 0

Bytewave
Bytewave

Reputation: 597

If what you had was in fact successfully copying the files you wanted, then there's only one small tweak to make to your command.
You currently use a command that, yes, copies the directory structure and contents of the target folder, but doesn't copy the root. What you could do to fix this is simply create the root folder in the destination, like so:

XCOPY "C:\Utilities\" D:\destination\Utilities\ /s /i /w 

Upvotes: 2

Related Questions