Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
862 views
in Technique[技术] by (71.8m points)

command line - Batch print PDF files listed in a text file

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

I know that using:

"C:Program Files (x86)AdobeReader 10.0ReaderAcroRd32.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)AdobeReader 10.0ReaderAcroRd32.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)AdobeReader 10.0ReaderAcroRd32.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)AdobeReader 10.0ReaderAcroRd32.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...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...