By default, Gnome does not provide a print option in the right-click menu of the file browser. Luckily it is very easy to add more functions to this menu.

Nautilus will look into the ~/.gnome2/nautilus-scripts folder and add the files it finds there to the 'scripts'-entry in the context menu that pops up whenever your right-click a file.

Create a file called 'print.sh' in this folder and paste the following script in it:

#!/bin/bash
#
# print.sh
#
# Print files from the right-click context menu in Nautilus.
# Place this script in ~/.gnome2/nautilus-scripts.

# The printer to use (as shown in the Printer Configuration
# gui or in /etc/cups/printers.conf).
printer=HP-Color-LaserJet-CP1215

echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | while read file
    do
        lpr -P "$printer" "$file"
done
exit 0

Replace "HP-Color-LaserJet-CP1215" with your own printer model. You can find the exact model name in the CUPS printer configuration GUI (Ubuntu: System > Administration > Printing).

Save the file, and make it executable:

$ sudo chmod u+x ~/.gnome2/nautilus-scripts/print.sh

From now on you can easily print multiple files directly from the file manager without having to open them first.

Reference:
Ubuntu: Printing with a mouse right-click - the inspiration for this article.

Share this
  1. dan (not verified) on Fri, 08/13/2010 - 00:10

    this doesn't seem to work for me. when i execute the lpr command from the terminal it works fine, but the script appears to do nothing. do you have any idea how i can troubleshoot it? thanks
    dan

  2. Pieter on Thu, 09/16/2010 - 15:20

    did you make the script executable?

  3. Richard (not verified) on Sat, 11/20/2010 - 13:35

    Hi
    Thanks for the tip!
    Can this be adapted somehow to enable printing direct to pdf (from rt click context menu)?
    Grateful for your advice!
    Many thanks

  4. Pieter on Sat, 11/20/2010 - 17:45

    Sure, you can add a virtual PDF printer with Cups-PDF. On Ubuntu you can install it with:

    $ sudo apt-get install cups-pdf

    A new printer named "PDF" will be added. Use this line in the script:

    printer=PDF

  5. Anonymous (not verified) on Tue, 08/02/2011 - 19:52

    thank you friend it was very useful!!! God bless you

  6. Anonymous (not verified) on Mon, 08/08/2011 - 08:59

    Seems to be a small typo. Initially, the file is called 'print.sh', but in the terminal command below, it's called 'printING.sh', so copy-pasting that command line would fail... Thanks for a great idea though!ondexte

  7. Pieter on Thu, 08/11/2011 - 22:41

    Well spotted :) I'll fix it. Thanks!!

  8. Anonymous (not verified) on Sun, 09/25/2011 - 14:52

    Hi,

    Thanks for the idea. Its really working like a charm.

    I have one input & one question.
    Input: when we use printer=PDF, the file goes to the ~/PDF folder. ( After some googling i found this).
    Question: Can i print all the documents into one pdf instaed of individual pdfs ?

  9. Anonymous (not verified) on Sat, 01/28/2012 - 15:51

    oh i love you for that script thaaanks a lot

  10. Jorge (not verified) on Wed, 07/25/2012 - 15:43

    Really Great, thanks for the contribution!

  11. Job (not verified) on Sun, 12/23/2012 - 12:59

    Brilliant!

  12. Post new comment

    The content of this field is kept private and will not be shown publicly.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
    • Syntax highlight code surrounded by the {syntaxhighlighter SPEC}...{/syntaxhighlighter} tags, where SPEC is a Syntaxhighlighter options string or "class="OPTIONS" title="the title".
    • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
    • Lines and paragraphs break automatically.

    More information about formatting options

    CAPTCHA
    This question is for testing whether you are a human visitor and to prevent automated spam submissions.
    By submitting this form, you accept the Mollom privacy policy.