Tuesday, September 4, 2018

Excluding certain file extensions from a recursive Copy-Item

One user was using PowerShell's Copy-Item cmdlet to copy an entire directory structure and wanted to avoid copying certain file extensions. Copy-Item has a -Filter parameter, but more conveniently it has an -Exclude parameter that takes a simple array of file name patterns to skip. So using -Exclude '*.mp3', '*.exe' will skip copying MP3 and EXE files.

No comments:

Post a Comment