windows 如何通过cmd复制文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19517429/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:01:14  来源:igfitidea点击:

How to copy a folder via cmd?

windowsbatch-filecmd

提问by Yordan Sirakov

I want to make a .bat file that when opened will copy a folder and all it contains into another folder on another partition. Here is exactly what I am trying to do:

我想制作一个 .bat 文件,打开时会将一个文件夹及其包含的所有内容复制到另一个分区上的另一个文件夹中。这正是我想要做的:

Copy C:\Documents and Settings\user\Desktop\Документиand all it contains to D:\Backup. I have tried with many xcopycommands but without result. Thanks.

C:\Documents and Settings\user\Desktop\Документи其包含的所有内容复制到D:\Backup. 我尝试了很多xcopy命令,但没有结果。谢谢。

I launched the command prompt with /kand saw this

我启动了命令提示符/k并看到了这个

pic

图片

which made me think there is a problem with the font. I installed new font that should fix this (YGP_NT) but I am having the same problem (yes, I changed it from the cmd Properties, edited the TrueTypeFont with regedit and restarted the PC). I can write in cyrillic in the cmd if that can help.

这让我觉得字体有问题。我安装了应该解决这个问题 ( YGP_NT) 的新字体,但我遇到了同样的问题(是的,我从 cmd 属性更改了它,使用 regedit 编辑了 TrueTypeFont 并重新启动了 PC)。如果有帮助,我可以在 cmd 中用西里尔文书写。

回答by Joey

xcopy "%userprofile%\Desktop\Документи" "D:\Backup\" /s/h/e/k/f/c

should work, assuming that your language setting allows Cyrillic (or you use Unicode fonts in the console).

应该可以工作,假设您的语言设置允许西里尔文(或者您在控制台中使用 Unicode 字体)。

For reference about the arguments: http://ss64.com/nt/xcopy.html

有关参数的参考:http: //ss64.com/nt/xcopy.html

回答by harry gates

xcopy  e:\source_folder f:\destination_folder /e /i /h

The /h is just in case there are hidden files. The /i creates a destination folder if there are muliple source files.

/h 以防万一有隐藏文件。如果有多个源文件, /i 会创建一个目标文件夹。

回答by npocmaka

xcopy  "C:\Documents and Settings\user\Desktop\Документи" "D:\Backup" /s /e /y /i

Probably the problem is the space.Try with quotes.

可能是空间的问题。用引号试试。