I would like to copy an entire folder to other folder. NOT JUST the content of that folder.
For that I would like to do it in the CMD terminal.
FolderOriging1
/---folderA
/---folderB
/---folderC
FolderDesteny
/---empty
Result that I like:
FolderDesteny
/---folderA
(with folderA
including all the files and folders and subfolders)
I saw several posts here & here for instance
They all end up copying the contents of folder A, but not the folder itself.
for instance:
xcopy C:\folderA C:\folderB /E
this copies the contents of folder A to folder B
xcopy C:\folderA C:\folderB\folderA /E
Does not work neither
Other modifiers like the one pointed out in the above posted link do not work neither:
xcopy C:\folderA C:\folderB /E /i
The reason xcopy C:\\folderA C:\\folderB\\folderA /E
does not work is because folderA
does not exist in C:\\folderB
. Which is evident from the directory structure in your question:
/folderA
/folderB
/folderC
You need to use the /I
switch to create the directory if it does not exist. So your command should be:
xcopy C:\folderA C:\folderB\folderA /E /I
Note that Microsoft also advises to use the /O
, /X
, /H
and /K
switches with xcopy
when you want to retain the folder's permissions. There effects follow:
/H - Copies hidden and system files also.
/K - Copies attributes. Typically, Xcopy resets read-only attributes.
/O - Copies file ownership and ACL information.
/X - Copies file audit settings (implies /O)
Source: HOW TO: Copy a Folder to Another Folder and Retain its Permissions
If you would like more information about copying a folder and its contents to another folder using xcopy
and alternatives to using xcopy
, then check out this Super User question: Commmand line command to copy entire directory (including directory folder) to another directory .
Try this:
echo d|xcopy /E "c:\folderA" "C:\folderB\folderA"
The d
will serves as the interactive choice d
for folder.
Or just
xcopy /E "c:\folderA" "C:\folderB\folderA\"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.