Pergunta

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

Foi útil?

Solução

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

Outras dicas

Try this:

Get-ChildItem C:\test\AB*.zip | % {
    $output = $_.fullname -replace '\w{2}$', '\'
    & "C:\test\7z.exe" "x" "-y" $_.fullname "-o$output"
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top