Reputation: 273
i have some 100 text files in a folder temp_files
and this is how i am printing them
for /f %%B in ('dir temp_files\*.txt /b') do (
start /min notepad /P temp_files\%%B
)
the files are printing fine, but they are not printing in order. for example, when i echo the output like this
for /f %%B in ('dir temp_files\*.txt /b') do (
echo start /min notepad /P temp_files\%%B>>print_order.txt
)
in print_oreder.txt the order is correct, this is how the print_order.txt looks:
start /min notepad /P temp_files\location_1_product_1.txt
start /min notepad /P temp_files\location_1_product_2.txt
start /min notepad /P temp_files\location_1_product_3.txt
start /min notepad /P temp_files\location_2_product_1.txt
start /min notepad /P temp_files\location_2_product_2.txt
start /min notepad /P temp_files\location_2_product_3.txt
but when the actual print comes, it is not in order, it is random order. this is how the actual print is coming, actual printing order
location_1_product_1.txt
location_1_product_3.txt
location_2_product_2.txt
is there any way to print in order like this, expecting print order:
location_1_product_1.txt
location_1_product_2.txt
location_1_product_3.txt
location_2_product_1.txt
location_2_product_2.txt
location_2_product_3.txt
please help. thank you.
Upvotes: 0
Views: 989
Reputation: 56180
You have a timing problem (you open some 100 processes, they are not guaranteed to execute in a particular order). Add a /wait
to wait for each process to finish before the next is started:
start /min /wait notepad /P temp_files\%%B
(Note: this will make your script much slower, but you have to wait for the printer anyways..)
Upvotes: 2