Unix/Linux Go Back    


Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

Batch file loop and increment value for condition

Windows & DOS: Issues & Discussions


Tags
batch-file

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-29-2015
cmccabe cmccabe is offline
Registered User
 
Join Date: Nov 2013
Last Activity: 24 January 2017, 7:54 AM EST
Location: Chicago
Posts: 1,012
Thanks: 569
Thanked 11 Times in 11 Posts
Batch file loop and increment value for condition

I am trying to have the below batch file do following two things:

1. only allow the values YES,yes,Y,y, or NO,no,N,n

2. increment the counter %var1 only if answer to question 2 is "y" and not able to get the syntax correct. If %var1%=1 then I am trying to display function :end. Thank you Linux.

Question 2

Code:
  set /P c=Do you want to send the DOSE report[y/n]?


Batch file as is:

Code:
@ECHO OFF
:: ask user 
 :choice
 set /P c=Has the check been done [y/n]
 if /i %c%==y (
 set /P c=Do you want to send the DOSE report[y/n]?
 ) else (
 if /i %c%==n goto check
 )
 :file
 if /i %c%==y ( 
 "L:\NGS\HLA LAB\total quality management\QC & QA\DOSE reports\DOSE reporting form.xlsm"
 ) else (
 if /i %c%==n goto goodbye
 )
 :check
 set /P c=Do you want to perform the check [y/n]
 if /i %c%==y (
 set /P c=please complete the check and click enter
 goto file
 ) else (
 if /i %c%==n goto goodbye
 )
 :goodbye
echo "goodbye"
TIMEOUT 2 /nobreak
exit

:: count loop
set var1=0
:loop
set /a var1=%var1%+1
if %var1% EQU 1 (
    goto end
) else (
    goto loop
)
:goodbye
echo "goodbye"
TIMEOUT 2 /nobreak
exit
:end
echo "the DOSE report has already been sent by %USERNAME% on %DATE% at   %TIME%"

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract batch based on condition abhi.mit32 Shell Programming and Scripting 9 03-21-2015 10:21 PM
Recursive search for string in file with Loop condition rkrish123 Shell Programming and Scripting 5 05-10-2013 03:44 AM
While loop is not reading next line in the file when IF condition is used. vdurai Shell Programming and Scripting 4 02-20-2012 01:20 AM
running a batch file in loop aemunathan Shell Programming and Scripting 1 05-21-2008 03:11 AM
SSH in batch mode and File-Handles in a loop DaveCutler Shell Programming and Scripting 3 04-03-2007 07:39 AM



All times are GMT -4. The time now is 01:18 PM.