Page 1 of 1

help with pipe in batch file

Posted: 24 Feb 2009 12:27
by csalisonb
I'm trying to use the code snippet from --
"File Line Count - Use FIND command to count file lines, store line count into a variable" in a batch file and every time I test it I get an error -- "| was unexpected at this time."

I copied the code directly from this page but it won't work for me. I'm not really a DOS person, but I need to get a small batch program working.

Can anyone tell me why this won't work?
for /f %%a in ('type "%file%"|find "" /v /c') do set /a cnt=%%a

Thanks

Posted: 24 Feb 2009 14:56
by paultomasi
You need to insert a ceret symbol. See below:

for /f %%a in ('type "%file%"^|find "" /v /c') do set /a cnt=%%a

Posted: 24 Feb 2009 15:36
by csalisonb
Thank you , thank you , thank you -- that works.

I've been trying to figure that out since yesterday.