Pregunta

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

¿Fue útil?

Solución

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

Otros consejos

Try this:

Get-ChildItem C:\test\AB*.zip | % {
    $output = $_.fullname -replace '\w{2}$', '\'
    & "C:\test\7z.exe" "x" "-y" $_.fullname "-o$output"
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top