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

有帮助吗?

解决方案

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

其他提示

Try this:

Get-ChildItem C:\test\AB*.zip | % {
    $output = $_.fullname -replace '\w{2}$', '\'
    & "C:\test\7z.exe" "x" "-y" $_.fullname "-o$output"
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top