Thursday, March 8, 2018

Xcopy batch file behavior



I have the following backup batch file:



xcopy C:\test.txt \\server\Data\user\"data test" /e /y /i



Why does it not only copy the file listed but proceeds to copy the whole root directory?



When I remove the switches it only copies the file. There is nothing in the description of those switches that seems to cause the behavior. They are there because I'm picking up where someone else left and all the batch files use these three switches.


Answer



According to my command line help, the /E switch copies directories and subdirectories:



XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]

[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+file2][+file3]...]


**/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.**

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...