Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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!

share|improve this question
add comment

4 Answers

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
share|improve this answer
    
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. –  Cumulus007 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
show 5 more comments

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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. –  David M. Sousa Jul 17 '12 at 1:33
add comment

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.

http://sourceforge.net/projects/duplexpr/
share|improve this answer
add comment

Your Answer

 
discard

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

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