I want to extract all .zip files in a given directory in temp using powershell

前端 未结 3 1461
一生所求
一生所求 2020-12-19 02:26

I wrote the following code for extracting the .zip files to temp:

function Expand-ZIPFile($file, $destination)
{
    $shell = new-object -com shell.applicati         


        
3条回答
  •  遥遥无期
    2020-12-19 03:21

    You can use this if you want to create a new folder for each zip file:

    #input variables
    $zipInputFolder = 'C:\Users\Temp\Desktop\Temp'
    $zipOutPutFolder = 'C:\Users\Temp\Desktop\Temp\Unpack'
    
    #start
    $zipFiles = Get-ChildItem $zipInputFolder -Filter *.zip
    
    foreach ($zipFile in $zipFiles) {
    
        $zipOutPutFolderExtended = $zipOutPutFolder + "\" + $zipFile.BaseName
        Expand-Archive -Path $zipFile.FullName -DestinationPath $zipOutPutFolderExtended
    
        }
    

提交回复
热议问题