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]
Name=Print Directly
Comment=Print file directly with default printer.
Exec=lp %f

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
  • Hi: thanks for your advice, but what if I want to print many files but no all the files on that dir? That's what I'd like to do, because as I new files get saved on that dir I only print the new files. Hope I explained it well :)
    – Oscar
    Jul 16 '12 at 20:46
  • That's really a different question to the original one asked, but I'll see if I can do something with the script- it might be tricky to just print the ones not already printed; although what we could do is just add a command to move each document to a specified folder after it has been printed. It should be possible to insert that into the while loop.
    – user76204
    Jul 16 '12 at 20:58
  • Please note that lpr only works on plain text. You will have to use another tool that sends a print job to CUPS if this is about PDFs, for instance.
    – user77111
    Jul 16 '12 at 21:14
  • Hi, not so different question, that's why I put "many" and "selected" in the question's name, so that can be all of them or some of them :D OK, hope you find a solution to achieve it. Many thanks!
    – Oscar
    Jul 16 '12 at 21:16
  • 1
    lpr does work with pdfs- the command lpr bash_FAQ.pdf does print it out perfectly.
    – user76204
    Jul 16 '12 at 21:17

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


This is not a direct solution for Ubuntu Linux Operating System:

  • Try using Google's service: Google - Cloud Print. Not sure if there is a one-step-multitask option, though

Also, a more complex solution:

Install nautilus-actions package

Execute the Nautilus Actions Settings from System > Preferences menu and add some action:

Action Tab

Nautilus Item

Context Label : Print

Display item in selection context menu

Display item in location context menu (not needed)

Action Properties: Enabled

Command Tab

Profile Label:

Default Command:

Path: lp

Parameters: %M (click on the legend button to see additional info)

Edit the other tabs information as you would like to your nautilus to behave.

Save the action, restart nautilus .

Your context menu will show up "Print"...

Source: UbuntuForums

Using a simple method:

Open a terminal and type lpr and put a space in front of it. Then drag and drop the files you want to print on the terminal.

  • Hi, I added the action and command in Nautilus as indicated, the menu appears when right clicking the file but nothing happens /: The terminal method did work, but when printing pdf files, the resulting printed page have other fonts and not the ones you see when opening with the visor.
    – Oscar
    Jul 16 '12 at 20:41
  • Sorry, but this is not my own knowledge. I gnawed at some sites to grab the information I just posted. You should check, on the Nautilus case, the lp's documentation. Maybe it isn't targeting your printer. Jul 17 '12 at 1:33

Recent versions of CUPS added the ability to print pdfs directly. 11.10 and newer (and possibly older) releases have this.

Another approach (that I use with my duplex (two-sided) printing emulator package) is to use Print To File for all your print jobs and put them in a folder that effectively becomes your personal print queue. Once they're there, you can print some or all of them when you want to and delete them when they're done.

This has the added advantage of allowing you to rerun jobs after a paper jam, etc. without recreating them from scratch. It also allows you to keep working without stopping to manage your printer.

If you want to, you could write a small script that would run in the background and start printing things that appear in your print queue. If you do any of this, you may want to name your print jobs so that they sort in the queue in the order you want them to print in. I just use 00 ... 99 for names.

For text files, look out for those that may have long lines. CUPS (at least by default) won't wrap the lines for you or set up nice page margins.

My duplex printing system does a lot more than what you're asking for, but might give you some ideas. Notably it has two small helper scripts dprint and dprintm which take text and tame it a bit before sending it to the printer.


I know this is old - but the way to do this is now revised as I discovered today:

you will need filemanager-actions installed - it was already on my system

sudo apt-get install filemanager-actions

Next get nautilus-actions

sudo add-apt-repository ppa:dr3mro/nautilus-actions-extra
sudo apt-get update
sudo apt-get install nautilus-actions

Open FileManager-Actions and create a new action as per above:

Action Tab
    Nautilus Item
        Display item in selection context menu (tick)
        Display item in location context menu (tick)
        Context Label : Print
        Display item in the toolbar (tick)
        Use same label for icon in the toolbar (tick)

Command Tab
        Label: Default profile
        Path: lp
        Parameters: %f
        Working directory: %d

Edit the other tabs information as you would like to your nautilus to behave.

Save the action, restart nautilus .

Your context menu will show up "Print"...

a few links helped me out: LibreOffice Print Right Click Print

  • 1
    PPA no longer working in 20.04
    – jonathan
    Dec 13 '20 at 10:35

Or use Ruby :-)

sudo apt-get install ruby
Dir.glob('*.*').each{ |f| `lp '#{ f }'` }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.