Solved

Batch print HTML files

Posted on 2007-11-14
10
3,081 Views
Last Modified: 2008-02-01
I have been trying for a while to create a batch file that will get all *.html files in a specfic directory and batch print them I have tried everything I know and spent days on the net. Does anyone know if this is even possible? Oh the other problem is that the printer is the default network printer!!! Any help would be greatly appreciated.

@echo off

c:

net use lpt1: /delete /y

net use lpt1: \\vactor_wts_nt1\mislaser
 

cd C:\Program Files\Internet Explorer

iexplore.exe /p /h C:*.html

pv -k -f iexplore.exe
 

Exit

Open in new window

0
Comment
Question by:roberta
  • 4
  • 3
  • 3
10 Comments
 
LVL 9

Expert Comment

by:MSE-dwells
ID: 20289060
Are you trying to print the html source or the rendered page?
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 20289228
To print the source you can use the vbscript from this article:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/dec05/hey1206.mspx

Unfortunately odd things seem to happen when printing .html files with it, so rename them all to .txt first using a command like this:
ren c:\documents\*.html *.txt

Then rename them back afterwards.
0
 
LVL 9

Expert Comment

by:MSE-dwells
ID: 20289496
Nod, sadly though I'm guessing the OP wants the rendered content -- got anything for that too?
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 20290597
Ok, found a way.

1. Create a page containing links to all the other pages.  You can use a command like the one attached below (remember to change all instances of %G to %%G if you put it in a batch file).

2. Open list.htm in Internet Explorer.

3. Go to File|Print.

4. Select the desired printer, then go to the Options tab.

5. Check the "Print all linked documents" box, then click Print.

I got the idea from this page:
http://lists.evolt.org/archive/Week-of-Mon-20011029/060218.html
for /F "tokens=*" %G in ('dir *.html /B') do echo ^<A HREF="%G"^>%G^</A^> >> list.htm

Open in new window

0
 
LVL 9

Expert Comment

by:MSE-dwells
ID: 20290619
Nice idea ... like it.  Hopefully, that'll meet the OP's requirements?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:roberta
ID: 20293031
Actually they are orders that are exported from an oracle based ERP system. Every night they are deposited in a network directory then retrieved one by one and printed accordingly. They were previously PDF files which I had written a batch file to print. Now the same command lines (modified of course) will not work.
0
 

Author Comment

by:roberta
ID: 20294997
I have tried the "list.htm" solution very clever but, the person/people who will be using this is a point and click user only. So any tips on writing an actual batch file or a standalone vbs script would be perfect. Thank you though for that tip it really is very cool.
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 20298081
Well, if you save the code below in a .cmd file and put it on their desktop then all they have to do is double-click it and go through printing steps 3-5.  I don't think it will get any friendlier than that without a specialized batch printing program.


@echo off

setlocal
 

REM The folder containing the .html files

set target=s:\JDE files
 

if exist "%temp%\list.htm" del "%temp%\list.htm"
 

for /F "tokens=* usebackq" %%G in (`dir "%target%\*.html" /B`) do echo ^<A HREF="%%G"^>%%G^</A^> >> "%temp%\list.htm"
 

"%programfiles%\internet explorer\iexplore.exe" "%temp%\list.htm"
 

endlocal

Open in new window

0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 20298521
Whoops, had an error.
@echo off

setlocal

 

REM The folder containing the .html files

set target=s:\JDE files

 

if exist "%target%\list.htm" del "%target%\list.htm"

 

for /F "tokens=* usebackq" %%G in (`dir "%target%\*.html" /B`) do echo ^<A HREF="%%G"^>%%G^</A^> >> "%target%\list.htm"

 

"%programfiles%\internet explorer\iexplore.exe" "%target%\list.htm"

 

endlocal

Open in new window

0
 

Author Comment

by:roberta
ID: 20312018
Thank you so much for the solution. The person who will be using it is more than happy to be clicking a couple of batch files rather than printing 50 or 60 documents individually.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now