help with pipe in batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
csalisonb
Posts: 2
Joined: 24 Feb 2009 12:03

help with pipe in batch file

#1 Post by csalisonb » 24 Feb 2009 12:27

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

paultomasi
Posts: 25
Joined: 24 Feb 2009 14:52
Location: UK
Contact:

#2 Post by paultomasi » 24 Feb 2009 14:56

You need to insert a ceret symbol. See below:

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

csalisonb
Posts: 2
Joined: 24 Feb 2009 12:03

#3 Post by csalisonb » 24 Feb 2009 15:36

Thank you , thank you , thank you -- that works.

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

Post Reply