Batch print PDF files listed in a text file

38,083

Solution 1

Run for /? in a cmd.exe Window and read the output, or see Loop command: against a set of files.

Basically, if you want to batch print all PDFs in a directory, you can do the following:

for %i in (*.pdf) do ^
  "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" /t %i

This is the line to be used if run directly in a 'DOS box' window. If run from a BAT file, you need to replace %i by %%i.

If you have the files-to-be-printed enumerated line by line in a *.txt file:

for /f %i in (mypdfs.txt) do ^
  "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe" /t %i

(Note: I didn't test-run the commands, since I don't have a Windows system around, but I'm relying on my aging memory here...

Solution 2

All, to expand on Kurt's answer ... this is what I did:


RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "Brother MFC-J6930DW Printer"
Timeout /T 10
CD\
cd Users\bill\Desktop\PrintMe
Timeout /T 2
for %%i in (*.pdf) do "C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe" /t "%%i"
Timeout /T 10
RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n "HP OfficeJet Pro 8710 (Network)"
Pause

This batch file will change default printers, print everything in folder, then change default printer back

Solution 3

Try 2Printer command line tool from: http://doc2prn.com/

Printing list of PDF documents command line example: 2Printer.exe -l "C:\input files.txt" -prn "Canon MP610"

2Printer is free!

Share:
38,083
victorxbox1980
Author by

victorxbox1980

Updated on January 04, 2020

Comments

  • victorxbox1980
    victorxbox1980 over 4 years

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

    I know that using:

    "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:

    "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.

  • David I. McIntosh
    David I. McIntosh over 11 years
    Kurt: out of interest, why do you use the ^ instead of ()?
  • Kurt Pfeifle
    Kurt Pfeifle over 11 years
    @DavidI.McIntosh: ^ and () are not the same. The ^ in above context simply is simply a line continuation sign (in other DOS contexts it is an escape char). I used it for formatting reasons, so every bit of my command is visible in the browser. In Unix, Linux and Mac one would have to use \. The () ` in a DOS batch file allows you to group command blocks (and also allows to use line breaks as Ken White did).
  • David I. McIntosh
    David I. McIntosh over 11 years
    Yes, I understand both well. I was just curious if you had a reason for presenting it the way you did as one logical line on two physical lines with ^ (it could equally well be presented on multiple physical lines using brackets). In the windows world, I have rarely seen anyone use ^ to escape the line-ending. Not that there is anything wrong with it, just wondering why you had a preference for it.
  • Kurt Pfeifle
    Kurt Pfeifle over 11 years
    @DavidI.McIntosh: You rarely see the usage of ^ in the Windows world because hardly any batch script author knows about it. I prefer it because it can be used even where brackets don't work (brackets can only be used in certain contexts).
  • David I. McIntosh
    David I. McIntosh over 11 years
    Thanks for the reply. This is what I was curious about. cmd.exe often has problems parsing when () are involved. I am curious if you have an example of where ^ would work but () fails? lol. I'm now going to have to do some experimenting when I have time...
  • David I. McIntosh
    David I. McIntosh over 11 years
    couldn't get the notification to work when editing the previous comment.
  • Jesus is Lord
    Jesus is Lord over 6 years