Hi All,
I have a module where I can take in zip files and then I unzip them to a specific directory. However, sometimes the zip files themselves have double-nested folders. e.g. a zip file
“book1.zip”… will contain a folder “book1” and then book1.txt. I want to keep the first level such that book1.zip will create
destfolder\book1\book1.txt…
but not
destfolder\book1\book1details\book1txt
However there aren’t always 2 levels… so I want to examine the zip file, check to count how many levels there are, and either extract, or else go into the zip file and then extract the subfolder.
Any ideas ? Many thanks
foreach ($i in $files) { write-output "$("Setting Location to Directory : ")$($i.DirectoryName)" set-location $i.Directoryname Write-Output "$("Expanding ")$($i.name)$(" to ")$($workdir)$("\")$($ComicsDir)$("\")$($i.basename)" $extractor = New-Object sevenzip.SevenZipExtractor($i.fullname) $extractor.ExtractArchive("$($ComicsDir)$("\")$($i.basename)") Remove-Item $i.name #$testempty = dir #if (!$testempty) #{ # cd .. # Remove-Item $i.directoryname # $testempty = $null #} }