Inside c:\test\
I have:
- .\dir1
- .\dir2
- .\dir3
and
- file1.txt
- file2.txt
- file3.txt
- file4.txt
I want to compress only dir1
, dir2
, file1.txt
and file2.txt
I use the following script to compress selected folders
$YourDirToCompress="C:\test\"
$ZipFileResult=".\result.zip"
$DirToInclude=@("dir1", "dir2")
Get-ChildItem $YourDirToCompress -Directory |
where { $_.Name -in $DirToInclude} |
Compress-Archive -DestinationPath $ZipFileResult -Update
How would I be able to add my selected files (file1.txt
& file2.txt
) to final compressed result.zip
?
Ideally I want the compression to happen in one go meaning I pass the list of selected files and folders and then do the compression.