[英]Function to create zip file excluding some files and folders in Powershell
How to write powershell script function to create a zip file excluding .tmp files and bin, obj folder 如何编写powershell脚本函数来创建一个不包含.tmp文件和bin,obj文件夹的zip文件
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 此代码压缩源目录的所有文件夹,但如何从zip中排除.tmp文件和源目录的“bin”,“obj”文件夹
尝试将这些开关添加到7Zip的命令行:
[Array]$arguments = "a", "-tzip", "$Zipfile", "$dir", "-xr!bin", "-xr!obj", "-xr!*.tmp";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.