How turn a folder into a print queue? On MacOS, you can drop a PDF directly onto the window of a Printer's print queue, and it will be sent to print immediately (with the printer's default settings).

I'm looking for a way to do a similar thing with a specified folder. E.g. Any PDF or PostScript file dropped onto that folder (or saved there through any other method) will be sent straight to the printer. 

The obvious thing is to use Folder Actions and an AppleScript, but I'm wondering if there's a neater solution that I've overlooked? Essentially, I'm looking for a filepath that works as a print queue.
There is a simpler solution in 4 steps and a small shell script:


make your own spool directory:

/usr/bin/sudo mkdir /var/spool/my_printer

write the following shell script within your usual local bin directory
let's say /local/bin

cd /local/bin


copy the following inside my_spooler:

#!/bin/sh

# go into the spool directory
cd /var/spool/my_printer

# main loop: loop till end of time
while : ; do

    # check for any newly arrived text file
    for _file in * ; do

       # if _file is a normal file, print and remove it (-r option to lpr)
        [ -f "${_file}" ] &amp;&amp; lpr -r "${_file}"
    done

    # don't loop like a fool
    sleep 300
done

make your my_spooler executable:

chmod u+x my_spooler

start it:

my_spooler &amp;


it should start without a full path if /local/bin is within your PATH
if it isn't, then start it this way:

/local/bin/my_spooler &amp;


The ending &amp; means start it in background so as not to block your session waiting until the end of time.


How to use it

To use it you simply have to move any text or PS or PDF file within your own defined spool directory how you prefer. Either with the Finder or with basic command line:

cp my_file.pdf /var/spool/my_printer