HANDLING STRING THROUGH IF AND ELSE IN DOS

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
aatman.kumar
Posts: 1
Joined: 04 Feb 2011 15:51

HANDLING STRING THROUGH IF AND ELSE IN DOS

#1 Post by aatman.kumar » 04 Feb 2011 15:55

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.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: HANDLING STRING THROUGH IF AND ELSE IN DOS

#2 Post by aGerman » 04 Feb 2011 17:01

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

Post Reply