7Zip4Powershell
7Zip4Powershell copied to clipboard
Cannot create archive from empty directory
Creating an archive from an empty directory results in the error message Compress-7Zip : Invalid file names have been specified: Message: the specified directory is empty!
and a zero byte (invalid) 7z file. Empty directories should not be a special case.
Running in the same issue. @thoemmi Maybe you could help here? What do we have for options?
edit: If someone running into the same issue here´s my workaround:
Import-Module 7Zip4Powershell
$Path = "D:\somepath\somefolder"
$Zip_Name = ("somefolder" + ".7z")
Write-Host $Path
if (Test-Path $Path) {
Compress-7Zip -ArchiveFileName D:\somepath\$Zip_Name -Path $Path -Format SevenZip
"Successfully compressed '$Path'."
}
else {
"Directory doesn´t exist."
}
I stopped working on the module many years ago, because I don't need it anymore. However, I'd be happy to incorporate any bug fixes.
So you options are either
- check, if the directory is empty before calling
Compress-7Zip
, or - fix the issue and send me a PR.