Zum Inhalt

Copying files with exclusions

If you need to copy files from one directory to another one and would like to exclude some files it can be done using PowerShell pretty easy.

$source = 'C:\Temp1\*'
$dest = 'C:\Temp2\'
$exclude = @('*.pdb','*.config')
Copy-Item $source $dest -Recurse -Force -Exclude $exclude

In line 3 you can simply add only one specific filename or as in this case simply exclude files based on their extensions.

Published inWindows

Schreibe den ersten Kommentar

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.