I want to write an expression that displays only the names of top-level folders from the archive, but for now only display all the contents. Has anyone come across this?

$x = & 'c:\Program Files\7-Zip\7z.exe' l -slt D:\2.zip $a = $x | Where-object {$_ -match '^path' } $a 

I get now the answer type

 Path = D:\2.zip Path = 1 Path = 1234.txt Path = 2 Path = 2\123.txt Path = 3 Path = 4 Path = 4\132131.txt Path = 4\41 Path = 4\41\141 

And I want to

 1 2 3 4 

    1 answer 1

    $a array of strings, so the only way is to truncate them:

     $x = & 'c:\Program Files\7-Zip\7z.exe' l -slt C:\test\res_2.zip | Where-object {$_ -match '^path' } | ForEach-Object { $a += ($_.Replace('Path = ','')) } $a