Vra

I use this command:

Get-ChildItem C:\test\AB*.zip | 
% {
    & "C:\test\7z.exe" "x" "-y" $_.fullname "-oC:\test\AB\"
}

I want to save in location which would be filename -2 symbols. Have any tips?

Thanks

Was dit nuttig?

Oplossing

try this way (not tested)

Get-ChildItem C:\test\AB*.zip | 
 % {
     $to  = $_.fullname.length - 2
     $path = $_.fullname.substring( 0, $to)
     & "C:\test\7z.exe" "x" "-y" $_.fullname "-o$path"
   }

Ander wenke

Try this:

Get-ChildItem C:\test\AB*.zip | % {
    $output = $_.fullname -replace '\w{2}$', '\'
    & "C:\test\7z.exe" "x" "-y" $_.fullname "-o$output"
}
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top