Page 1 of 1

Queue Script

Posted: 05 Jun 2020 06:11
by casper2201
Hello, I am currently trying to make a simple Queue Script and I have been looking around the net until i find this forum.
I need some help from the experts here.
Here is what I am trying to accomplish when printing the output of the bat file:

Code: Select all

line1: Current date
line2: Current time
line3: Your number
line4: Incremental number
line5: Thanks for waiting
Here is what I have done:
I have 10 text file by the name A001.txt - A010.txt
The content of the text files are:

Code: Select all

Your Number
A001                           <<<< up to A010
Thanks for waiting
Then I have another file that I run called "print.bat", the content of the file is:

Code: Select all

@echo off
notepad /p A001.txt
pause
notepad /p A002.txt
pause
notepad /p A003.txt
pause
notepad /p A004.txt
pause
notepad /p A005.txt
pause
notepad /p A006.txt
pause
notepad /p A007.txt
pause
notepad /p A008.txt
pause
notepad /p A009.txt
pause
notepad /p A010.txt
pause
This method get the jobs done but im looking for another simpler way to do this.
I have tried this method but it doesnt work:

Code: Select all

 echo %date% > test.txt
Time /T >> test.txt
echo Your number >> test.txt
set /A COUNTER=COUNTER+1 >> test.txt
echo pause >> test.txt
Can anyone here help me?
Thanks

Re: Queue Script

Posted: 06 Jun 2020 13:18
by penpen
This might help you (untested):

Code: Select all

@echo off
setlocal enableExtensions disableDelayedExpansion
for /l %%a in (1, 1, 10) do (
	call :createAnnn.txt "%%~a"
	call :printAnnn.txt "%%~a"
)


:createAnnn.txt
set "COUNTER=000%~1"
set "COUNTER=%COUNTER:~-3%"
>"A%COUNTER%.txt" (
	echo(%date%
	echo(%time%
	echo(Your number
	echo(A%COUNTER%
	echo(Thanks for waiting
)
goto :eof

:printAnnn.txt
set "COUNTER=000%~1"
set "COUNTER=%COUNTER:~-3%"
notepad /p "A%COUNTER%.txt"
pause
goto :eof
penpen