如何使用xcopy将子文件夹复制到子文件夹?(How to copy a subfolder into a subfolder using xcopy?)

编程入门 行业动态 更新时间:2024-10-28 10:30:17
如何使用xcopy将子文件夹复制到子文件夹?(How to copy a subfolder into a subfolder using xcopy?)

假设我在C:\test目录中,我有C:\test\myHugeFolder目录和C:\test\backup目录 - 我想将myHugeFolder从cmd.exe命令提示符复制到backup 。

所以,我认为通过使用相对路径, xcopy这种用法是正确的:

C:\test> xcopy myHugeFolder backup\ /s /e

问题是, xcopy在这里搅拌了15分钟,还列出了myHugeFolder每个文件,所以我认为一切都很好 - 然后当它完成时,我会查看backup ,而没有myHugeFolder ; 事实上,当我搜索myHugeFolder ,只有原始版本:

C:\test>dir myHugeFolder* /s Volume in drive C has no label. Volume Serial Number is FFFF-FFFF Directory of C:\test 18-10-2015 16:26 <DIR> myHugeFolder 0 File(s) 0 bytes Total Files Listed: 0 File(s) 0 bytes 1 Dir(s) 2.419.708.346.368 bytes free

所以,显然这不是正确的命令行 - 我哪里出错了, xcopy的正确调用是做什么样的副本?

Let's say I'm in C:\test directory, where I have C:\test\myHugeFolder directory and a C:\test\backup directory - and I'd like to copy myHugeFolder into backup from cmd.exe Command Prompt.

So, I thought this usage of xcopy is correct, by using relative paths:

C:\test> xcopy myHugeFolder backup\ /s /e

The thing is, xcopy here was churning for like 15 minutes, also listing each file in myHugeFolder, so I thought all was fine - then when it finished, I look into backup, and there no myHugeFolder; in fact when I search for myHugeFolder, there's only the original:

C:\test>dir myHugeFolder* /s Volume in drive C has no label. Volume Serial Number is FFFF-FFFF Directory of C:\test 18-10-2015 16:26 <DIR> myHugeFolder 0 File(s) 0 bytes Total Files Listed: 0 File(s) 0 bytes 1 Dir(s) 2.419.708.346.368 bytes free

So, obviously that is not the right command line - where am I going wrong, and what is the right invocation of xcopy to do this kind of a copy?

最满意答案

问题中的测试是错误的。

C:\test> dir myHugeFolder

此命令不会列出复制到C:\ test \ backup文件夹的任何内容。

正确的测试更像是这样的:

C:\test> dir backup

它会显示C:\ test \ myHugeFolder的内容被复制到C:\ backup ,而不是C:\ test \ backup \ myHugeFolder

如果想要在C:\ test \ backup \ myHugeFolder中复制C:\ test \ myHugeFolder ,一种方法是:

C:\test> XCOPY myHugeFolder backup\myHugeFolder /E /I

之后,以下命令将显示myHugeFolder容器的所需副本:

C:\test dir backup\myHugeFolder

The test in the question is wrong.

C:\test> dir myHugeFolder

This command will not list anything copied to the C:\test\backup folder.

A correct test is more like this:

C:\test> dir backup

It would show that the contents of C:\test\myHugeFolder was copied into C:\backup, not C:\test\backup\myHugeFolder.

If one wanted a duplicate of C:\test\myHugeFolder in C:\test\backup\myHugeFolder, one way to do that would be:

C:\test> XCOPY myHugeFolder backup\myHugeFolder /E /I

After which the following command would show the desired copy of the myHugeFolder container:

C:\test dir backup\myHugeFolder

更多推荐

本文发布于:2023-04-28 00:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329613.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   如何使用   subfolder   xcopy   copy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!