Benjamin Lindley
Benjamin Lindley

Reputation: 103733

How to copy all files from dir and all sub-dirs with a particular set of extensions into another dir?

Specifically, I want to write a powershell script to find every file with extensions.lib & .dll from directory X and all sub-directories of X recursively. Then I want to copy them to directory Y. All files should be put directly in Y, the directory structure of X is not to be copied.

Upvotes: 2

Views: 2363

Answers (1)

JPBlanc
JPBlanc

Reputation: 72650

According that Y exists :

Get-ChildItem -LiteralPath X -filter *.lib -Recurse | % {Copy-Item $_.fullname Y}
Get-ChildItem -LiteralPath X -filter *.dll -Recurse | % {Copy-Item $_.fullname Y}

Upvotes: 6

Related Questions