开发者

CMD Command to Copy files with certain extension

So I'm using this command to copy only txt files from a certain directory to another di开发者_运维问答rectory

for /R c:\source %%f in (*.xml) do copy %%f x:\destination\

But it only copies over the text files without a space in the name, so it copies test.txt but not test 2.txt. How do I make it so it copies txt files with spaces?


Add quotes just around the variable after the copy command:

for /R c:\source %%f in (*.xml) do copy "%%f" x:\destination\


What's wrong with

copy c:\source\*.xml x:\destination\ >nul

[Edit] Oh I see, you want to copy all the files in all directories recursively, but without copying the directory structure. Nevermind, then.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜