Reputation: 11
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
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!
Upvotes: 0
Views: 144
Reputation: 11
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 :)
Upvotes: 1
Reputation: 16246
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.
Upvotes: 0