简体   繁体   English

仅Xcopy某些文件名

[英]Xcopy certain file names only

I've never used the Xcopy feature before and I was wondering if it would be possible to use xcopy to copy only certain files within a directory tree. 我以前从未使用过Xcopy功能,我想知道是否有可能使用xcopy仅复制目录树中的某些文件。

For example, suppose I have the following documents: \\servername\\generateddocuments\\2014\\20141231\\GUID1.doc \\servername\\generateddocuments\\2014\\20141231\\GUID2.doc \\servername\\generateddocuments\\2015\\20150101\\GUID3.doc \\servername\\generateddocuments\\2015\\20150101\\GUID4.doc 例如,假设我有以下文件:\\ servername \\ generateddocuments \\ 2014 \\ 20141231 \\ GUID1.doc \\ servername \\ generateddocuments \\ 2014 \\ 20141231 \\ GUID2.doc \\ servername \\ generateddocuments \\ 2015 \\ 20150101 \\ GUID3.doc \\ servername \\ generateddocuments \\ 2015 \\ 20150101 \\ GUID4.doc

Now, suppose I have a spreadsheet that tells me which .doc files I need to copy: GUID1.doc GUID3.doc 现在,假设我有一个电子表格,告诉我需要复制哪些.doc文件:GUID1.doc GUID3.doc

Is there a way to base the xcopy on the spreadsheet(or txt document) so I don't copy the files I don't need? 有没有一种方法可以将xcopy基于电子表格(或txt文档),以便我不复制不需要的文件?

I don't think xcopy can read files to include from a file. 我不认为xcopy可以读取文件中包含的文件。 But you can create a batch file that does this: 但是您可以创建一个执行此操作的批处理文件:

for /F "tokens=*" %%A in (documents.txt) do (
   copy %%A x:\targetfolder\
)

Try typing HELP XCOPY at a command prompt and look at the /EXCLUDE parameter. 尝试在命令提示符下键入HELP XCOPY,然后查看/ EXCLUDE参数。 The documentation isn't quite correct, you can put a list of files in a single file, one file name per line, and they will be excluded from the xcopy. 该文档不是很正确,您可以将文件列表放在一个文件中,每行一个文件名,这些文件将从xcopy中排除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM