Conditional Statements inside Batch

I need to create some statements inside a batch file that is similiar to the following:

Set Jobname = %1

If the jobname contains "Weekly" and today is Sunday then

set WaitFile=E:\Console\Nightly_Finished_TodaysDate.txt
Call GenerateFile

If the jobname contains "Static" and today is Sunday then

set WaitFile=E:\Console\Weekly_Finished_TodaysDate.txt
Call GenerateFile

If the jobname contains "Nightly" then
set WaitFile=E:\Console\ALog_Finished_TodayDate.txt
Call GenerateFile

If the jobname contains "Validate" and today is Saturday then

set WaitFile=E:\Console\Nightly_Finished_TodayDate.txt

Call GenerateFile


@echo off

sleep 1
if not exist "%WaitFile%" goto loop
REM Additional code below here ..

Can anyone assist or offer a better way to handle?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

opposed to a vbscript solution?
It's possible in a batch file to grab the day's name, but cumbersome...
earngreenAuthor Commented:
Not oposed to vbscript
Not sure what your script does beyond this, but this would be the start of it...let me know if you'd like the rest of the batch included here...
Jobname = lcase(wscript.arguments(0))
Today = lcase(WeekdayName(Weekday(Date))
TodayDate = Year(Date) & Month(Date) & Day(Date)
WaitFolder = "E:\Console\"
If Jobname = "" Then wscript.quit
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
If Instr(Jobname, "weekly") > 0 And Today="sunday" Then
ElseIf Instr(Jobname,"static") > 0 And Today="sunday" Then
ElseIf Instr(Jobname,"nightly") > 0 Then
ElseIf Instr(Jobname,"validate") > 0 And Today="saturday" Then
End If
WaitFile = WaitFolder & Replace(WaitFile, "TodayDate", TodayDate)
wscript.sleep 1000
If Not objFSO.FileExists(WaitFile) Then
 'do something...
End If

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

earngreenAuthor Commented:
The rest of the batch is just inserting a record into a database similiar to this
Set CN = CreateObject("ADODB.Connection")

CNString = "Driver={SQL Server}; Server=; Database=; UID=; PWD="
CN.ConnectionString = CNString
StrsqlQry = "INSERT INTO Job(Jobname, 'TodaysDate(dd/mm/yy hh:mm:ss)', 'Started','') values(StartTime,JobName,Status,EndTime)"
cn.execute StrsqlQry

The only question that I have with your code(Jobname = lcase(wscript.arguments(0))
) accept a parameter in the same manner as %1 for batch.

The last thiing is there a way to do a check with the sleep function that this fails after n hours of checking for the file

Yes, it takes the first argument (similar to %1) and converts it to lowercase for comparison.

For the checking, you could do something like:
(will basically wait for 30 minutes)

For x = 0 to 120
  wscript.sleep 15000  'sleep 15 seconds before retesting
  If objFSO.FileExists(WaitFile) Then Exit For

earngreenAuthor Commented:
This does not seem to want to call the argument. When i run from command line it just does nothing.
earngreenAuthor Commented:
Figured it out. Thanks for the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.