我们可以使用 robocopy 来复制文件而不是文件夹吗
我需要将特定文件从一个位置复制到另一个位置。是否可以使用 robocopy 执行相同操作。
I need to copy a particular file from one location to another., Is it possible to use robocopy to do same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
虽然可以说服 Robocopy 复制单个文件,但使用 copy 或 xcopy 则要简单得多。
Whilst Robocopy can be persuaded to copy a single file it is much simpler to use copy or xcopy.
是的,要么将其包装在 exec 中,要么使用包装为 msbuild 扩展包一部分的 Robocopy,请参阅:http://www.msbuildextensionpack.com/help/4.0.3.0/index.html
您想要使用 MSBuild.ExtensionPack.FileSystem.RoboCopy 任务。
使复制速度更快。
Yes, either wrap it in an an exec or use the Robocopy that is wrapped as part of the msbuild extension pack see:http://www.msbuildextensionpack.com/help/4.0.3.0/index.html
You want to use the MSBuild.ExtensionPack.FileSystem.RoboCopy task.
Makes copying much quicker.
我试图解决这个问题。我终于找到了自己的解决方案,也许会有所帮助。
我注意到用于选择整个目录的语法可以用于选择单个文件。
上面的代码会将目录源文件夹中的所有内容复制到目录输出路径。
假设您只想从名为“test.txt”的目录源复制 1 个文件,
为此请使用以下代码:
就是这样。它工作得非常好,只会复制您想要的文件名。
或者,您可以使用
从目录源复制出所有文本文档。
同样,这也适用于任何 .ext
.zip .exe .txt .pdf 等。
我注册是为了用更好的方法回答这个问题。如果我成功了请告诉我。
I was trying to figure this problem out. I finally found my own solution and maybe it will help.
I noticed that the syntax used to select the entire directory could be used to select a single file.
The above code will copy everything from the directory source folder to the directory output path.
Let's say you only wanted to copy 1 file from the directory source named "test.txt"
In order to do that use the following code:
Thats about it. It works really well and will only copy the file name you want.
Alternatively you can use
to copy out all text documents from the directory source.
Similarly this will also work with any .ext
.zip .exe .txt .pdf etc..
I signed up to answer this question with a better method. Let me know if I succeeded.