batch print

Microsoft Windows
Post Reply
User avatar
MigrationUser
Posts: 336
Joined: 2021-Jul-12, 1:37 pm
Contact:

batch print

Post by MigrationUser »

14 Sep 2012 02:33
victorxbox1980


Hello I am new to CMD but I would like to make a batch printing solution.

I know that using:

Code: Select all

"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" /t "C:\file_1.pdf"
I can print file_1.pdf but what I really need is to print multiple files, let's say file_2, file_3... file_n, therefore my instruction will change to:

Code: Select all

"C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" /t "C:\XXXX.pdf"
I thought about making a TEXT file where I could write the name of the files that I need to print. Then in a batch file make a loop that will read each line of the TEXT and change my variable XXXX for the name of the file specified in each row of the TEXT.

Is this possible? I'm not stupid and I learn fast so, if any body can point me in the right direction of how to do variables in batch files, and how to read information form a TEXT it would be fantastic!!

Thank you very much

and have a great day.

- victor -

----------------------------

#2 14 Sep 2012 14:08
bluesxman


Should be easy enough:

Code: Select all

@echo off

set "input=C:\some directory\yourList.txt"

for /f "usebackq tokens=*" %%F in ("%input%") do (
    if exist "%%~F" (
        echo:Printing: "%%~F"
    "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" /t "%%~F"
    ) else (
        echo:Not found: "%%~F"
    )
)
Where "C:\some directory\yourList.txt" contains:

C:\file_1.pdf
C:\file_2.pdf
C:\file_3.pdf

Last edited by bluesxman (14 Sep 2012 14:15)

cmd | *sh | ruby | chef

----------------------------

#3 17 Sep 2012 11:06
victorxbox1980


Thank you very much...

It works, not as I was expecting but it does... the only problem is that I have to manually close Adobe Reader so the script can go ahead an read the next line of the Text file and do the printing of the next PDFs.

I tried to kill the process but it only allows me to kill Adobe Reader after I have already manually closed it so, it gives me an error saying that Adobe Reader is not found and It continues with the second line of the Text file and so on.

So now I am trying to find on the web if somebody knows how to terminete with AcroRd32.exe after a period of time of beeing open as I read in fome forum somewhere but for VB.

But thank you now I know about the use of FOR /F... Thanks you give me good starting point.

Regards

-vic-

----------------------------

#4 17 Sep 2012 11:20
bluesxman


It's a bit kludgey, but you could do this:

Code: Select all

@echo off

set "input=C:\some directory\yourList.txt"

for /f "usebackq tokens=*" %%F in ("%input%") do (
    if exist "%%~F" (
        echo:Printing: "%%~F"
        start "" "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" /t "%%~F"
        REM wait 10 seconds...
        ping 127.1 -n 11 >nul
        REM kill any Acrobat Reader processes
        taskkill /f /im "AcroRd32.exe"
    ) else (
        echo:Not found: "%%~F"
    )
)
cmd | *sh | ruby | chef

----------------------------

#5 17 Sep 2012 18:12
Simon Sheppard


One other thing to try is adding the /n switch: AcroRd32.exe" /n /t

That will allow multiple reader instances to open at once, which should then close automatically when the print jobs complete, so you wont need to kill anything. This could use a lot of RAM if there are a lot of documents, so you may still want a short delay between sending each print job.

Command line switches for Adobe Reader:

AcroRd32.exe options

pathname — Display the file, whose full path must be provided.
/n — Launch a separate instance of Adobe Reader, even if one is currently open.
/s — Suppress the splash screen.
/o — Suppress the open file dialog.
/h — Open in a minimized window.
/p filename — Print a file.
/t path printername drivername portname — Print a file while suppressing the print dialog box, then terminate Reader.

----------------------------

#6 17 Sep 2012 23:34
victorxbox1980


Thank you very much to both of you.

I've tried both options and killing the process it seems to be the best option. I've just printed 800 pdf's and while doing it I was able to grab a cup of coffee! and not having to be in front of the computer opening each file and manually print each one of them and then having to close them.

I am very happy to know that in this crazy world there is still people willing to help others :clap: GOOD JOB mates.

Regards

-victor-

----------------------------

#7 18 Sep 2012 01:01
victorxbox1980


Just 1 more question to Simon:

- Do you know if any of this switches can help me to only print just the first page?
Because I look everywhere without success in the INTRODUCTION TO SDK at:
http://livedocs.adobe.com/acrobat_sdk/1 ... 22.31.html

Regards

-Victor-
Post Reply