zipto7z.ps1 (499B)
1 # DESCRIPTION: convert all .zip files in current directory to .7z 2 # DEPENDENCIES: requires 7z.exe to be in your $PATH 3 Foreach ($zip in $(Get-ChildItem -Filter *.zip)) { 4 Set-Variable -Name name -Value $zip.toString().TrimEnd(".zip") 5 If (Test-Path "$name.7z") { continue } 6 7 Write-Output "$name" 8 Expand-Archive -Path "$zip" 9 10 Set-Location "$name" 11 7z a -mx9 "$name" 12 13 Move-Item "$name.7z" .. 14 Set-Location .. 15 16 If (Test-Path "$name.7z") { 17 Remove-Item "$zip" 18 Remove-Item "$name" -Recurse 19 } 20 }