Search code examples
printingcmdadobeghostscript

How to print multiple PDF files in different folders?


An example would be:

 Folder 1:
  a.pdf
  b.pdf
   Folder11
   c.pdf
  Folder 2:
  a.pdf
  b.pdf
   Folder21:
   c.pdf

printing all files between folders

And the cmd would have a way to find the file only putting part of the words? Example

TEXT : ABC*.PDF

PRINT ABCDF.PDF


Solution

  • 1. To loop over multiple files recursively:

    FOR /f "tokens=*" %%F in ('dir /s /b *.pdf') DO echo "%%F"
    
    • dir /s /b *.pfd finds all pdfs (*.pdf), in all subdirectories (/s), in bare format - ie just the path name (/b)
    • DO echo "%%F" just echo's the result to the console.
    • "tokens=*" adds the whole line into %%F regardless of white spaces / other tokens
    • /F makes it run the ('dir ...') command

    2. To print from command line use: From this question

    AcroRd32.exe /t "C:\Folder\File.pdf" "Brother MFC-7820N USB Printer" "Brother MFC-7820N USB Printer" "IP_192.168.10.110"
    

    Note: Path to AcroRd32.exe must be in your path environment variable

    3. Putting it all together -- edit -- 'I've added taskkill to close acrord32 after printing

    FOR /f "tokens=*" %%F in ('dir /s /b *.pdf') DO AcroRd32.exe /t "%%~F" "Brother MFC-7820N USB Printer" "Brother MFC-7820N USB Printer" "IP_192.168.10.110" & taskkill /IM AcroRd32.exe