Reputation: 361
How to write powershell script function to create a zip file excluding .tmp files and bin, obj folder
I tried and found this:
function create-zip([String] $dir, [String] $Zipfile){
[string]$pathZipExe = "C:\Program Files\7-zip\7z.exe";
[Array]$arguments = "a", "-tzip", "$Zipfile", "$dir";
& $pathZipExe $arguments;
}
This code zip all file folder of the source directory but how to exclude .tmp files and "bin", "obj" folders of the source directory from zip
Upvotes: 1
Views: 3299
Reputation: 60928
Try adding these switches to 7Zip's command line:
[Array]$arguments = "a", "-tzip", "$Zipfile", "$dir", "-xr!bin", "-xr!obj", "-xr!*.tmp";
Upvotes: 3