I have a nested folder structure for example like this (it's a lot more for simplicity I put an example)
- folder1
- folderA
a.zip
- folderB
b.zip
I want to unzip all zip files in same folder and delete the original zip file.
so my expected output is like
- folder1
- folderA
- a
files in a.zip
- folderB
- b
files in b.zip
I can get list of all zip files by Get-ChildItem '.' -R -Filter *.zip command
Then also I can pipe it to unzip like
Get-ChildItem '.' -R -Filter *.zip | Expand-Archive -Force -DestinationPath c:\a
which giving a fixed destination path Also I can able to get the folder name of each zip file by
Get-ChildItem '.' -R -Filter *.zip | select -ExpandProperty DirectoryName
also I tried
Get-ChildItem '.' -R -Filter *.zip | Expand-Archive -Force -DestinationPath $_.DirectoryName
and
Get-ChildItem '.' -R -Filter *.zip | Expand-Archive -Force -DestinationPath %{$_.DirectoryName}
also
Get-ChildItem '.' -R -Filter *.zip | Expand-Archive -Force -DestinationPath {$_.DirectoryName}
But I can't find a way to pass the DirectoryName to Expand-Archive command