powershell - resolve object variable from foreach-object -


i'm trying extract files extention .sddb out of archives in folder extention .sdbz.

here how tried it:

from folder contains file test.sdbz

get-childitem -filter "*.sdbz" | foreach-object {.\7za.exe x $_.name -o *.sddb} 

it seems $_.name not resolved becaus if use command

7za.exe x test.sdbz -o *.sddb 

from command line works fine.

can me please? in advance!

first of all, replies. found error , solution.

i made mistake of thinking command works in cmd work in powershell.

cmd version

"7za.exe x test.sdbz -o.\ *.sddb" 

the -o.\ tell 7zip extract working directory.

it works in cmd not in powershell.

powershell version

here how solved it:

$workingdirectory = pwd dir -filter "*.sdbz" | foreach-object { .\7za.exe x $_.name -o"$workingdirectory" *.sddb} 

so $_.name part worked along. xd


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -