How to send to print (many) selected files in a directory instead of one by one?

I'm using Ubuntu 12.04 and succesfully installed my wi-fi printer, but my question is: How to print many files at a time? I mean, I have many PDF or text files in a folder and I want to send them directly to printer instead of opening one by one in file viewer and then to print and then repeat the whole process so many times /:

I even see no Print option when right clicking on the file or in the File menu.

Thank you!


Create the file: ~/.local/share/applications/print.desktop Put in:

[Desktop Entry]
Encoding=UTF-8
Name=Print Directly
Comment=Print file directly with default printer.
Exec=lp %f
Type=Application
Icon=/usr/share/pixmaps/gnome-applets.png
MimeType=text/plain;text/pdf;application/pdf;application/x-pdf

Right click on any pdf file, in the "Open with..." view the extended list of available application for pdf files. Find the "Print Directly" entry and add the association. From now on you can right click on any pdf file (or groups) and have them printed with the lp command on your default printer. If you want to make experiments, install the CUPS-PDF printer and set it as default in the Printers settings.

sudo apt-get install cups-pdf

You will have test file "printed" into ~/PDF folder.


I have done a script that will send the desired files to the default printer: you may have to modify it to select the folder that your files are in and run it once for .pdf and then for .txt:
find /home/mike/KeyGuides/ -type f -iname '*.txt' -print0 | while IFS= read -r -d '' f; do lpr "$f"; done. It does work as I have just tested it; just make sure the desired printer is set up as default.

If you have any problems, I'll see if I can modify it as necessary. (You can use other options for lpr if you need -see man lpr) It should work for most printers- it is successful with my Canon IP4700.

This version of the script also moves each printed document to a directory (which you must have created previously), so that when the script is run only new documents are printed:

find /home/mike/Duck/ -type f -iname '*.txt' -print0 | while IFS= read -r -d '' f;
 do lpr "$f" && mv "$f" /home/mike/Duck/printed/ ; done

The solution to this is very simple. Go to the desired folder and, in a terminal do:

for FILE in *.pdf ; do lpr "$FILE" ; done

This is from https://ubuntuforums.org/showthread.php?t=921960