How to copy a directory structure but only include certain files (using windows batch files)

Posted by Martin on Stack Overflow See other posts from Stack Overflow or by Martin
Published on 2009-01-23T12:18:36Z Indexed on 2010/06/18 10:53 UTC
Read the original article Hit count: 225

Filed under:
|
|
|

As the title says, how can I recursively copy a directory structure but only include some files. E.g given the following directory structure:

folder1
  folder2
    folder3
      data.zip
      info.txt
      abc.xyz
    folder4
    folder5
      data.zip
      somefile.exe
      someotherfile.dll

The files data.zip and info.txt can appear everywhere in the directory structure. How can I copy the full directory structure, but only include files named data.zip and info.txt (all other files should be ignored)?

The resulting directory structure should look like this:

copy_of_folder1
  folder2
    folder3
      data.zip
      info.txt
    folder4
    folder5
      data.zip

© Stack Overflow or respective owner

Related posts about Windows

Related posts about batch-file