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
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)"
Write-Output "$("Expanding ")$($i.name)$(" to ")$($workdir)$("\")$($ComicsDir)$("\")$($i.basename)"
$extractor = New-Object sevenzip.SevenZipExtractor($i.fullname)
#$testempty = dir
# cd ..
# Remove-Item $i.directoryname
# $testempty = $null
Interesting idea.. yes that could take me towards the answer.
Now same question would apply... when I expand them.. how can I do a run across to say... "if there is one subdirectory in the temp folder then move it to the final folder... if there are 2 or more lower subdirectories, then move to the bottom one and move *that* to the final folder"?