Solved

Batch print HTML files

Posted on 2007-11-14
10
3,176 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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