Discussion:
Direct input from console to LOOP
(too old to reply)
2006-06-01 17:47:19 UTC
Permalink
I'm trying to write a batch file that will print labels on a thermal
printer. I already have the code to make the label print by using the "copy
/b file.prn lpt1". Now I want it to loop this command for however many
labels they want printed. I've been beating my brains in for the past 2
days ( haven't messed with DOS for quite some time ) and just can't get it
to take the input as a variable and pass it to the loop.

Example of what I want this thing to do:

Ask: How many labels would you like to print? ( input a number from 1 to
100 here )

Take that number and send it to a loop to run this command "copy /b file.prn
lpt1" until it reaches the amount they want and then end.

any help would be appreciated.

Thanks,

Mike
Mario Díaz
2006-06-01 23:35:02 UTC
Permalink
Mike:
I hope this work for you

count.bat
---------------------------------------------
@echo off
set count=
:loop
set count=%count%-
copy /b file.prn lpt1
if not "%count%"=="%1" %then% goto loop
%else% set count=
---------------------------------------------
usage: you must pass a string parameter "-" with the lenght of the copies.
example with 5 copies:

count.bat -----

take care of the environmment space when printing a lot of labels...
Post by
I'm trying to write a batch file that will print labels on a thermal
printer. I already have the code to make the label print by using the "copy
/b file.prn lpt1". Now I want it to loop this command for however many
labels they want printed. I've been beating my brains in for the past 2
days ( haven't messed with DOS for quite some time ) and just can't get it
to take the input as a variable and pass it to the loop.
Ask: How many labels would you like to print? ( input a number from 1 to
100 here )
Take that number and send it to a loop to run this command "copy /b file.prn
lpt1" until it reaches the amount they want and then end.
any help would be appreciated.
Thanks,
Mike
vdar@msft
2006-06-04 14:51:30 UTC
Permalink
Another option:

:: PrintLables.cmd

@Echo Off
cls
setlocal

Set /p Lables=How Many Lables Would You like to Print? &REM

for /L %%a in (1, 1, %Lables%) do (
echo.Printing %%a of %Lables%
copy /b file.prn lpt1
)
endLocal
goto:eof
Post by
I'm trying to write a batch file that will print labels on a thermal
printer. I already have the code to make the label print by using the "copy
/b file.prn lpt1". Now I want it to loop this command for however many
labels they want printed. I've been beating my brains in for the past 2
days ( haven't messed with DOS for quite some time ) and just can't get it
to take the input as a variable and pass it to the loop.
Ask: How many labels would you like to print? ( input a number from 1 to
100 here )
Take that number and send it to a loop to run this command "copy /b file.prn
lpt1" until it reaches the amount they want and then end.
any help would be appreciated.
Thanks,
Mike
Loading...