Solved

Batch print HTML files

Posted on 2007-11-14
10
3,371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

691 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