7Zip4Powershell icon indicating copy to clipboard operation
7Zip4Powershell copied to clipboard

Cannot create archive from empty directory

Open GSPP opened this issue 7 years ago • 2 comments

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.

GSPP avatar Feb 12 '18 10:02 GSPP

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."
}

Scifire avatar Nov 16 '20 15:11 Scifire

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.

thoemmi avatar Nov 16 '20 16:11 thoemmi