Reputation: 31
I installed the PowerShellPack to zip multiple files into zip.
It works with small files like .txt, but not with large files.
Only one file is in the zip and I get the error File not found or no read permission
.
Import-Module PowerShellPack
Copy-ToZip -File "D:\Temp\Test.adi" -zipfile "D:\Temp\Files.zip"
Copy-ToZip -File "D:\Temp\Test2.adt" -zipfile "D:\Temp\Files.zip"
I tried to use the Wait-Job command, but this also only works with small files. With large files a zip-file is created, but it is empty.
Import-Module PowerShellPack
$job = Start-Job {Copy-ToZip -File "D:\Temp\Test.adi" -zipfile "D:\Temp\Files.zip"}
Wait-Job $job
Receive-Job $job
$job = Start-Job {Copy-ToZip -File "D:\Temp\Test2.adt" -zipfile "D:\Temp\Files.zip"}
Wait-Job $job
Receive-Job $job
Upvotes: 3
Views: 5263
Reputation: 169
I recommend using the Write-Zip cmdlet included in the PowerShell Community Extensions instead. It doesn't have the file access problems that Copy-ToZip has.
Example usage:
Get-ChildItem D:\Temp\*.ad* | Write-Zip -OutputPath D:\Temp\Files.zip
If -OutputPath
is not specified, a zip file will be created for each input file rather than a single zip file.
It also has a -Level
switch to specify compression level.
Upvotes: 3