Question

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

Était-ce utile?

La solution

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"
   }

Autres conseils

Try this:

Get-ChildItem C:\test\AB*.zip | % {
    $output = $_.fullname -replace '\w{2}$', '\'
    & "C:\test\7z.exe" "x" "-y" $_.fullname "-o$output"
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top