How to batch print multiple PDFs from multiple (sub)folders in linux (command line, find, xargs and lpr)
Use the command line command
lpr on Linux to print several files (in this case PDFs) from several folders in the same tree.
I needed to print several PDF files which were in several folders under a main folder. Ex. Folder1/pdf1.pdf, Folder2/Folder3/pdf2.pdf, and so on.
To open each folder and each file to print them was too much time and work, and I didn't find a way to use [Nemo] to print all the files.
I have used
xargs before, and I found the command
lpr allowed me to print from the terminal. (I wrote an article which also uses
xargs some time ago here: How to find files using Regex (Regular Expressions) in GNU/Linux and MacOs command line and do something.)
After searching for some information (see References), I used the following line to search for all the files in all the subfolders and send their paths to
This should work if the printer you want to use is set as default. If you want to use a specific printer check the last references, which uses the argument
-P "$printer" with
lpr to set a printer.
This will print all the files found with find in the folder you are in.
Printing a file from the right-click context menu in Nautilus
file browser in Linux Mint
- 2022-12-22 08:30 How to find all processes with a specific string in their name and kill them all (in linux command line using ps, grep and awk)
- 2022-11-17 15:00 How to copy files to remote server through SSH Tunnel using ngrok and rsync (quick-note)
- 2022-11-03 15:00 How to download Google Takeout files (150GB+) with wget (on a remote server)
- 2021-06-10 17:54 How to import several folders with files into WordPress Media Library using wp-cli
- 2020-06-02 17:06 How to manage several SSH Config files on Mac and Linux (quick-note)
- 2019-03-24 07:30 How to find files using Regex (Regular Expressions) in GNU/Linux and MacOs command line and do something.
CommentsComments powered by Disqus