How to print PDF files automatically from a directory?
-
Install the package
inoticoming
sudo apt-get install inoticoming
-
Install the package
trash-cli
to use your trash folder instead of deleting the PDFsudo apt-get install trash-cli
If you prefer the deletion of the file via the classical
rm
, than you don't need this package and you have to replace the linelpr "$2/$1" && trash "$2/$1"
with
lpr "$2/$1" && rm "$2/$1"
in the script below.
-
Create wrapper script
printpdf
mkdir -p ~/bin gedit ~/bin/printpdf
-
Add the code below, save the file and close the editor
#!/usr/bin/env bash FILE="$1" if [ "${FILE##*.}" = "pdf" ] then lpr "$2/$1" && trash "$2/$1" fi exit 0
-
Make the script executable
chmod +x ~/bin/printpdf
-
Watch your folder
inoticoming /path/to/MY-SHARED ~/bin/printpdf {} /path/to/MY-SHARED \;
And as @Rmano said in the comments
About point 4, notice that is practically impossible to be sure that the file has been printed. You can check it has been sent to the printer, but printed is quite more complex and really never fail-proof (and probably printer-dependent).
Related videos on Youtube
![maryuri sanzonetti](https://lh3.googleusercontent.com/-f1AZfaVPKQA/AAAAAAAAAAI/AAAAAAAAACw/5Or23GOXCaY/photo.jpg?sz=256)
maryuri sanzonetti
Updated on September 18, 2022Comments
-
maryuri sanzonetti almost 2 years
Currently, I have a directory called MY-SHARED, and I need the following to happen:
- Print all PDF files that I place into MY-SHARED
- The printing must initiate automatically (no human interaction)
- After printing, it should automatically delete the file
How can I accomplish such task?
As a side note, I'm novice in the Ubuntu world.
-
Rmano almost 9 yearsAbout point 4, notice that is practically impossible to be sure that the file has been printed. You can check it has been sent to the printer, but printed is quite more complex and really never fail-proof (and probably printer-dependent).
-
Rmano almost 9 years+1, even if you forgot to delete the file after printing (or at least moving in a trash, on the line of
lpr [...] && mv file trash
) ;-) -
A.B. almost 9 years@Rmano Ups o_O =)
-
maryuri sanzonetti almost 9 yearsGreat guys, now all my home computers can print to the Epson L200 printer installed on the station with Zorin 9.1. At home my dad has a notebook with Linux Canaima. And now I need not install drivers. Also happens to my mom using a Chromebook like mine, it's just print the PDF to said network folder and everything working. Thanks very much, I love you a world ;-*
-
maryuri sanzonetti almost 9 yearsIf I have a problem I call to 0800 ASKUBUNTU GUYS! hehehe