我可以使用单个“复制”命令在Windows命令行上复制多个命名文件吗?命令? [英] Can I copy multiple named files on the Windows command line using a single "copy" command?

查看:125
本文介绍了我可以使用单个“复制”命令在Windows命令行上复制多个命名文件吗?命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为构建后事件的一部分,我想将几​​个已知文件复制到另一个目录,但是我不想在一行中包含 copy [file] [destination] [switchs]这一行构建事件。如果可能的话,我想使用类似的格式列出要复制的文件:复制[文件1] [文件2] [文件3] [etc ...] [目标] [开关] 。但是,Windows似乎不喜欢这种格式。有任何想法吗?谢谢!

I'd like to copy several known files to another directory as a part of a post-build event, but don't want to have lines and lines of "copy [file] [destination] [switches]" in my build event. If possible, I'd like to list out the files I'd like to copy using a similar format: "copy [file 1] [file 2] [file 3] [etc...] [destination] [switches]". However, Windows doesn't seem to like this type of format. Any ideas? Thanks!

推荐答案

您可以在批处理文件中或直接在命令提示符下使用'for':

You can use 'for' either in a batch file or directly from the command prompt:

for %I in (file1.txt file2.txt file3.txt) do copy %I c:\somedir\

文件列表中也支持通配符:

Wildcards are supported in the filelist as well:

for %I in (*.txt *.doc *.html) do copy %I c:\somedir\

有关更多信息,只需键入/?在命令提示符下,或者为了更轻松地阅读帮助,请使用开始->帮助和支持,然后搜索对于。在我的XP Pro盒子上,它是全文搜索结果中的第15项。

For more info, just type for /? from a command prompt, or for a much easier to read help use Start->Help and Support and search for "For". On my XP Pro box, it was item 15 in the full text search results.

这篇关于我可以使用单个“复制”命令在Windows命令行上复制多个命名文件吗?命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆