简体   繁体   English

将整个文件夹(不仅仅是内容)复制到cmd终端中的另一个文件夹中

[英]copy a whole folder (not just contents) into another folder in cmd terminal

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. 为此,我想在CMD终端中进行。

FolderOriging1 FolderOriging1

/---folderA
/---folderB
/---folderC

FolderDesteny FolderDesteny

/---empty

Result that I like: 结果我喜欢:

FolderDesteny
/---folderA

(with folderA including all the files and folders and subfolders) (包含folderA包括所有文件和文件夹以及子文件夹)
I saw several posts here & here for instance 我在这里这里看过几个帖子
They all end up copying the contents of folder A, but not the folder itself. 它们最终都会复制文件夹A的内容,但不会复制文件夹本身。

for instance: 例如:

xcopy C:\folderA C:\folderB /E

this copies the contents of folder A to folder B 这会将文件夹A的内容复制到文件夹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 . xcopy C:\\folderA C:\\folderB\\folderA /E不起作用的原因是因为在C:\\folderB中不存在folderA 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. 如果目录不存在,则需要使用/I开关创建目录。 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. 请注意,当您要保留文件夹的权限时,Microsoft还建议将/O/X/H/K开关与xcopy配合使用。 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 . 如果您想了解复制文件夹及其内容使用其他文件夹的详细信息xcopy和替代使用xcopy ,然后看看这个超级用户的问题: 条命令行命令复制整个目录(包括目录文件夹)到另一个目录

Try this: 尝试这个:

echo d|xcopy /E "c:\folderA" "C:\folderB\folderA"

The d will serves as the interactive choice d for folder. d将作为互动选择d的文件夹中。

Or just 要不就

xcopy /E "c:\folderA" "C:\folderB\folderA\"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将子文件夹的内容复制到另一个文件夹 - Copy contents of subfolder to another folder 如何使用cmd将一个文件夹(不仅是其内容)克隆到另一个文件夹? - How to clone a folder(not only its contents) into another folder using cmd? Windows cmd 批处理文件,复制源文件夹和内容 - Windows cmd batch file, copy source folder and contents 使用.bat脚本复制整个文件夹 - Copy whole folder with .bat script 使用目录上的通配符从文件夹复制内容 - Copy Contents From Folder Using Wildcard On The Directory 复制文件夹(包括内容)并粘贴到带有日期的存档文件夹中 - Copy Folder (contents included) and Paste in Archive Folder with Date 批处理文件以检查文件中是否存在特定单词“test”,如果存在则将整个文件夹复制到另一个位置 - batch file to check if the specific word “test” exist in the files, IF exist copy the whole folder to another location rsync复制文件夹和内容,而不只是Windows上的内容 - rsync copying folder and contents instead of just contents on windows 如何在 Python 中将所有文件夹内容从一个位置复制到另一个位置? - How do I copy all folder contents from one location to another location in Python? Python如何将所有文件夹内容从一个位置复制到另一个位置? - How do I copy all folder contents from one location to another location in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM