Powershell 将所有文件解压缩到一个文件中,而不创建其他文件

Powershell 将所有文件解压缩到一个文件中,而不创建其他文件,powershell,Powershell,我有两个文件夹中的大量zip文件。每个文件夹中的每个zip文件都以some100.zip、some200.zip和some300.zip结尾命名。大约1000个zip文件以大约100.zip结尾,以此类推 我想进入每个文件夹,解压所有以some100.zip结尾的文件,并将解压后的内容(我不想/不需要解压后生成的每个文件)连接到一个文件中 我试着在5个文件上测试下面的代码,但最终在每个文件夹中都有5个以压缩文件名命名的文件夹和解压缩文件。我需要一个单独的文件,其中包含所有5个文件的连接数据 $l

我有两个文件夹中的大量zip文件。每个文件夹中的每个zip文件都以some100.zip、some200.zip和some300.zip结尾命名。大约1000个zip文件以大约100.zip结尾,以此类推

我想进入每个文件夹,解压所有以some100.zip结尾的文件,并将解压后的内容(我不想/不需要解压后生成的每个文件)连接到一个文件中

我试着在5个文件上测试下面的代码,但最终在每个文件夹中都有5个以压缩文件名命名的文件夹和解压缩文件。我需要一个单独的文件,其中包含所有5个文件的连接数据

$logList="Folder one", "Folder two";

for ($i=0; $i -lt $logList.length; $i++) {
    cd $logList[$i];

    $zips = Get-ChildItem "*.zip"
    foreach ($z in $zips) {
        Expand-Archive $z | Where-Object {$_ -match 'some100'} | Set-Content ('unzipped.txt')
    }

    cd ..
}
像这样的

$tempDir = "D:\TEMP\some100"
$destinationFile = "D:\TEMP\unzipped.txt"

$folders = @("Folder One", "Folder Two")

del $destinationFile -ErrorAction SilentlyContinue

$folders | %{
    $zips = Get-ChildItem  $_ -Filter *.zip

    $zips | %{
        if ($_.Name.EndsWith("some100.zip"))
            { Expand-Archive $_.FullName -DestinationPath $tempDir -Force }
    }
}

Get-Content "$($tempDir)\*" | Add-Content $destinationFile
像这样的

$tempDir = "D:\TEMP\some100"
$destinationFile = "D:\TEMP\unzipped.txt"

$folders = @("Folder One", "Folder Two")

del $destinationFile -ErrorAction SilentlyContinue

$folders | %{
    $zips = Get-ChildItem  $_ -Filter *.zip

    $zips | %{
        if ($_.Name.EndsWith("some100.zip"))
            { Expand-Archive $_.FullName -DestinationPath $tempDir -Force }
    }
}

Get-Content "$($tempDir)\*" | Add-Content $destinationFile