Solved findstr is working in CMD line but not working in Batch

February 28, 2014 at 07:42:25
Specs: Windows 7
Good Morning!!

Can anyone help me out for below issue ?

The below Findstr command is working fine when i run in command line but it is not working when i run as a batch script.

FINDSTR /M /C:"Error" %OutputFolder%\FB1_Out.txt > Err.txt

The output of the command is : Name of the filename.

message edited by suhailabbas

See More: findstr is working in CMD line but not working in Batch

Report •

February 28, 2014 at 08:58:50
This worked fine as a test for me.

set OutputFolder=d:\test
FINDSTR /M /C:"Error" %OutputFolder%\FB1_Out.txt>err.log

what is the error that you are getting?


Report •

February 28, 2014 at 09:41:02
✔ Best Answer
Check the value of %OutputFolder%. It's either subtly incorrect, or it has spaces.

How To Ask Questions The Smart Way

Report •

March 3, 2014 at 04:46:26
I am not getting any error : It just not writing any thing in the Err.txt when i run as batch .

From cmd line, it is writing properly to the Err.txt file.

I tried by giving proper path also,

FINDSTR /M /C:"Error" D:\test\471\Custom\Run\FB1_Out.txt>Err.log

Report •

Related Solutions

March 3, 2014 at 11:39:21
First of all, make sure you are conistant between "err.txt" and "err.log", since both have been referred to in this thread.
Maybe for some reason the output is going to a different directory. Run the batch, then search your entire system for the file and see if it is cropping up elsewhere with the date that you ran the batch: (just do this from the commandline, not as a batch)
cd \
dir /s /a err.*

Or, alternatively:
dir c:\ /s /a err*.* | find "mm/dd/yyyy"
Where the date matches your DIR format (usually as given above).

Or, fully qualify the path to the err file in your batch so you know for sure where it's going.

Report •

March 3, 2014 at 11:46:19
Yeah, at this point I'd need to see the actual error you're getting, the batch script, and an indication on where the error is coming from.

How To Ask Questions The Smart Way

Report •

March 4, 2014 at 02:04:49
Actually im using err.txt only. Sorry for the above confusion.

Now its working fine for me. Actually before findstr command im running one batch which creates the FB1_Out.txt and in this file i need to look for error.

What i did is after running batch i pause the process for 1 min using Sleep 60. THen findstr is working fine for me. THanks for the inputs guys

Report •

Ask Question