Computing.Net > Forums > Programming > To check if a string is present in a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

To check if a string is present in a file

Reply to Message Icon

Name: Gods
Date: October 9, 2009 at 08:45:44 Pacific
OS: Windows XP
CPU/Ram: 2.992 GHz / 1021 MB
Product: Dell / Optiplex gx270
Subcategory: Batch
Comment:

I need to Find the presence of a String in the first line of a file and if its available then do a set of actions else exit



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: October 9, 2009 at 08:57:38 Pacific
Reply:

setlocal
set /p a=<file.txt
if "%a:searchstring=%" == "%a%" then (
echo searchstring NOT found in file.txt
) else (
echo searchstring FOUND in file.txt
)


0
Reply to Message Icon

Related Posts

See More


Create a batch fiile move file based on text i...


Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: To check if a string is present in a file

How to check if a file is opened www.computing.net/answers/programming/how-to-check-if-a-file-is-opened/6494.html

C++ can you check if a file exists? www.computing.net/answers/programming/c-can-you-check-if-a-file-exists/11411.html

checking if a form is open in vb www.computing.net/answers/programming/checking-if-a-form-is-open-in-vb/2207.html