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

前端 未结 15 1683
半阙折子戏
半阙折子戏 2020-12-07 07:50

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
  folde         


        
15条回答
  •  攒了一身酷
    2020-12-07 08:08

    If Powershell is an option, you can do this:

    Copy-Item c:\sourcePath d:\destinationPath -filter data.zip -recurse
    

    The main disadvantage is it copies all folders, even if they will end up being empty because no files match the filter you specify. So you could end up with a tree full of empty folders, in addition to the few folders that have the files you want.

提交回复
热议问题