0

I want to extract a file in in windows, right after search for it, like this:

7z [args] | ls | grep filename

In my windows batch script, its:

7z [args] | dir /B | findstr filename

the search alone works perfectly like in linux, but i just cant pass it forward to a variable, or straight to 7z as an input.

I tried

  • pipe from the left
  • pipe from the right
  • for /f "delims=" %%a in ('dir /B ^| findstr onboard.zip') do @set Value=%%a

But all my solutions crashed with error.

My idea to pass the found file to any variable, OR give it straight forward to the extracting tool. Do you have any working solution/workaround for this? Thanks in advance!

2 Answers 2

1

After 1.5 days i realized that DIR have built in search, that can solve my problem without the pipe:

dir /b *filename

but still really interested in your - pipe included - solution :)

Sign up to request clarification or add additional context in comments.

Comments

0

I am not quite sure of what you want. Does 7z produce a list of filenames?

for /f "usebackq tokens=*" %f in (`7z [args]`) do (if exist "%f" echo found file "%f")

If this is used inside a batch script, the percent characters must be doubled.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.