xcopy deletes the directory.

Asked 2 years ago, Updated 2 years ago, 38 views

The directory structure is as follows:

~
│  
--src
│  t test.txt
│  t test02.txt
│  │  
│  --save01
│  t tmp.csv
│  │      
│  s-save02
--target
    │  
    --save01
    s-save02

Now we used the following command to copy the text file from the src directory to the target directory:

xcopy src\*.txt target/s/y

This will remove the save01 directory from the target directory.
I know that if I remove the /s option, it won't be deleted, and I understand that the copy command, not xcopy, is sufficient in the first place, but I don't know why the save01 directory is deleted, so I'm worried.Please let me know.

windows

2022-09-30 18:41

2 Answers

I will reproduce it with the xcopy command in Windows 7/Windows Server 2012.

In this case, the implementation of xcopy "/S" appears to be flawed.
I can't see the sauce, so it's just my imagination, but I guess it's like this.

·Copy only the directory tree ("/S" specified, excluding empty directories)
·Copy the matching files in the copied directory tree
"·""/S"" is specified, so delete the directory tree that you copied with an empty destination directory

"


2022-09-30 18:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.