开发者

Can we use robocopy to copy files instead of folders

I need to copy a particular file from one location to another., Is it possible to use robo开发者_运维百科copy to do same.


Whilst Robocopy can be persuaded to copy a single file it is much simpler to use copy or xcopy.


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.


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.

ROBOCOPY "*" "Directory source" "Directory Output unc path or non"

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:

ROBOCOPY "*test.txt" "Directory source" "Directory Output unc path or non"

Thats about it. It works really well and will only copy the file name you want.

Alternatively you can use

ROBOCOPY "*.txt" "Directory source" "Directory Output unc path or non"

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜