Page 1 of 1

HANDLING STRING THROUGH IF AND ELSE IN DOS

Posted: 04 Feb 2011 15:55
by aatman.kumar
I need a batch script in which
I have to check in a file for "RUNNING" string, if it is not there then i have t
o generate a file Named with "Start_JOB" and if i found the "RUNNING" string in
to file then i have to do a additional check for a file into a folder and then i
have to delete that file.

Re: HANDLING STRING THROUGH IF AND ELSE IN DOS

Posted: 04 Feb 2011 17:01
by aGerman
For the example I imagined some file names.
aatman.kumar wrote:
I have to check in a file for "RUNNING" string

This file is named "searchHere.txt" in my example.

aatman.kumar wrote:
if it is not there then i have to generate a file Named with "Start_JOB"

You didn't tell us a file extension, thats why I don't use an extension :|

aatman.kumar wrote:
and if i found the "RUNNING" string into file then i have to do a additional check for a file into a folder and then i have to delete that file.

I called this file "deleteMe.txt" and I hope the string is really all caps.

Code: Select all

@echo off &setlocal

findstr /c:"RUNNING" "searchHere.txt" >nul &&(
  if exist "deleteMe.txt" del "deleteMe.txt"
) || (
  >"Start_JOB" echo Your File Content
)

Regards
aGerman