Debby Pulido
Debby Pulido

Reputation: 55

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.

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

Now, suppose I have a spreadsheet that tells me which .doc files I need to copy: 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?

Upvotes: 1

Views: 2109

Answers (2)

John Kuhns
John Kuhns

Reputation: 506

Try typing HELP XCOPY at a command prompt and look at the /EXCLUDE parameter. 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.

Upvotes: 0

GolezTrol
GolezTrol

Reputation: 116100

I don't think xcopy can read files to include from a file. But you can create a batch file that does this:

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

Upvotes: 2

Related Questions