pipeline in For loop

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
doscode
Posts: 175
Joined: 15 Feb 2012 14:02

pipeline in For loop

#1 Post by doscode » 22 May 2012 12:50

Hello,
can I use pipeline in for loop?

Code: Select all

FOR /F "tokens=1 delims=" %R IN ('convert "file2.bmp" -crop 300x100+340+400 -fuzz 5% -fill black +opaque #660000 -fill white -opaque #660000 txt:- | grep white') DO  ( echo %R  )


Error: | not expected.

Aacini
Expert
Posts: 1932
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: pipeline in For loop

#2 Post by Aacini » 22 May 2012 13:04

Just escape the pipeline with a caret:

Code: Select all

FOR /F "tokens=1 delims=" %R IN ('convert "file2.bmp" -crop 300x100+340+400 -fuzz 5% -fill black +opaque #660000 -fill white -opaque #660000 txt:- ^| grep white') DO  ( echo %R  )

doscode
Posts: 175
Joined: 15 Feb 2012 14:02

Re: pipeline in For loop

#3 Post by doscode » 22 May 2012 13:06

Thanks

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: pipeline in For loop

#4 Post by Squashman » 22 May 2012 19:35

All you had to do was look at the previous thread you started and looked at the script that was written for you.

Post Reply