Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a folder with hundreds of small PDF files to print.
How can I make a batch job to print them out in alphabetical order?

share|improve this question

3 Answers 3

dir /b | sort > %temp%\files.tmp
for /f %f in (%temp%\files.tmp) do AcroRd32.exe /t %f "\\servername\printername"
del %temp%\files.tmp
share|improve this answer
    
thanks for your solution. anyway how come windows explorer sorts files in a different order? –  Jess Stone Feb 10 at 8:27
    
nobody knows why ? –  Jess Stone May 7 at 9:23

Details here about silent print command in Adobe reader.

so you can do (batch file):

for %%X in (*.pdf) do AcroRd32.exe /t %%X "\\servername\printername"

or (cmd prompt):

for %X in (*.pdf) do AcroRd32.exe /t %X "\\servername\printername"
share|improve this answer
    
Hi this does not guarantee the print in alphabetical order. :( –  E_M Mar 5 '10 at 11:44
    
Well, it does the same as a standard DOS dir *.pdf so it should be in order... –  Shevek Mar 5 '10 at 12:02
    
try this to prove the sort order: for %X in (*.pdf) do echo %X –  Shevek Mar 5 '10 at 12:06
    
don't work... just try. I create files: 3.pdf, 1.pdf, 2.pdf in a folder. then your command: C:\1>for %X in (*.pdf) do "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.ex e" /t %X C:\1>"C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" /t 1.pdf C:\1>"C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" /t 2.pdf C:\1>"C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" /t 3.pdf but in the printer I found this order of printing: 2-1-3. LOL! :) –  E_M Mar 5 '10 at 12:08
    
that doesn't make sense!!! if the command is executed 1,2,3 then it should print 1,2,3... –  Shevek Mar 5 '10 at 16:37

I know this isn't stackoverflow, but the only way I could do this would be in python.

Recepie for printing pdf file:

from win32com import client
import time

ie = client.Dispatch("InternetExplorer.Application")

def printPDFDocument(filename):

    ie.Navigate(filename)

    if ie.Busy:
        time.sleep(1)

    ie.Document.printAll()
    time.sleep(2)

ie.Quit()

Recepie for list all files from a dir:

   import os
   path="C:\\somedirectory"  # insert the path to the directory of interest here
   dirList=os.listdir(path)

Recepie for sorting alfabetically the list of files:

a.sort()  # a is the list

Well just by joining the 3 recepies, you can have your problem solved.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.