从多个目录某些扩展到一个目录中的批处理文件复制文件 [英] batch file Copy files with certain extensions from multiple directories into one directory
问题描述
我是个新手,所以忍耐一下...
I'm a newbie, so bear with me...
我试图复制所有 .DOC
,我已经遍布一个主目录的几个子目录到使用批处理文件的另一个目录中的文件。我已经得到了一个 Filelist.txt中
所有我想用复制的文件(有数百个)这些目录的:
I am trying to copy all .doc
files that I have scattered throughout several subdirectories of one main directory into another directory using a batch file. I have managed to get a filelist.txt
of all the files (there are hundreds) out of these directories that I want to copy using:
C:\\主目录\\子目录
DIR / B / S的* .doc> C:\\主目录\\子目录\\ Filelist.txt中
什么剧本我会使用这些XCOPY到一个目录?我可以使用一些code,实际上从 Filelist.txt中
抓住这些文件的名称和xcopies他们?
What script would I use to xcopy those into one directory? Can I use some code that actually grabs those file names from filelist.txt
and xcopies them?
有关参考,我看了看下面的问题,因为它看上去就像是在做我想做的事,但它并没有为我工作。
For reference, I looked at the question below because it looked like it was doing what I want to do, but it didn't work for me.
<一个href=\"http://stackoverflow.com/questions/585091/using-xcopy-to-copy-files-from-several-directories-to-one-directory\">Using XCOPY从多个目录中的文件复制到一个目录
另外,我真的想理解这个概念,所以请打破code,我要告诉我的每一项做什么,或者至少包含一个链接,解释它。
Also, I would really like to understand this concept, so please break down the code for me to tell me what each item does, or at least include a link that will explain it.
推荐答案
在一个批处理文件解决方案
In a batch file solution
for /R c:\source %%f in (*.xml) do copy %%f x:\destination\
在code的工作原理等;
The code works as such;
为每个文件为
在目录 C:\\源
和子目录 / R
的匹配模式(\\ *。xml的)
把文件名变量 %%˚F
,然后为每个文件不要
拷贝文件复制%%˚F
目的地 X:\\\\目的地\\\\
for each file for
in directory c:\source
and subdirectories /R
that match pattern (\*.xml)
put the file name in variable %%f
, then for each file do
copy file copy %%f
to destination x:\\destination\\
这里只是测试它在我的Windows XP计算机上和它的工作对我来说就像对待。但我键入它进入命令提示符,所以我用了一个%F
变量名的版本,如上面的链接的问题描述。
Just tested it here on my Windows XP computer and it worked like a treat for me. But I typed it into command prompt so I used the single %f
variable name version, as described in the linked question above.
这篇关于从多个目录某些扩展到一个目录中的批处理文件复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!