Can Windows' copy command handle multiple files?

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

You can use this in either a batch file or directly from the command line. Not as clean as *nix, but it works.


Windows includes robocopy built in, which copies multiple files from a single command:

robocopy a\source\folder a\dest\folder file1.docx file2.exe

It's worth noting that if you have a wildcard expression rather than an explicit list of files then COPY does copy all the files to the target directory:

COPY srcdir\* destdir\
COPY *sy?.* anotherdestdir\

Anyone coming from a *nix background would find it particularly confusing that while works while explicit lists don't, because in Unix-like shells they're indistinguishable to a program – the shell expands any wildcards, so the program ends up with an explicit file list either way. This doesn't apply here because the Windows command shell passes wildcards directly through to programs and it's up to them to do expansion. (Also COPY is a built in command in the shell rather than an external program like cp on Linux, so in principle it could potentially disobey the usual rules about command line arguments, but that actually doesn't apply here.)