Copy Files with exact Structure into another Directory using XCopy

Inside Man picture Inside Man · Sep 5, 2011 · Viewed 8.7k times · Source

Think I want to copy this file C:\Majid\File\text.txt to D:\Copied (C:\Majid\File\text.txt ---> D:\Copied)

I want to use Xcopy to copy that file with its full directory into D:\Copied, then I should have something like this ---> D:\Copied\Majid\File\text.txt , as you see the drive letter is removed and all of other directory is created in destination directory.

How can I do this action by XCopy?

Answer

Davide Piras picture Davide Piras · Sep 5, 2011

see this:

XCOPY COMMAND

... Syntax xcopy Source [Destination] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d[:mm-dd-yyyy]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a|/m}] [/n] [/o] [/x] [/exclude:file1[+[file2]][+[file3]] [{/y|/-y}] [/z] ...

what you will find interesting in that page is this:

/s : Copies directories and subdirectories, unless they are empty. If you omit /s, xcopy works within a single directory.