Windows archives extract

From snippet wiki
Jump to navigation Jump to search

How to extract several hundred archives under windows? Use the PowerShell with this short loop:

 foreach ($file in Get-ChildItem Z:\downloads\*.7z)
 {
  Write-Host $file
  Set-Variable mybname -value $file.BaseName
  Write-Host $mybname
  Set-Variable mycommand -value "c:\tools\7za x -oZ:\ziel\$mybname -y $file"
  Write-Host $mycommand
  invoke-expression "$mycommand"
 }