Automate printing with specific print settings using Hazel & shell script

Glad to hear it helped! I too use this to route 4x6 thermal labels to my thermal printer, and other letter-sized print jobs to my laser printer.

I can just save the PDFs to the default Downloads folder, and my Hazel rules have been built to detect file names and file content to route them to the proper printer.

So nice to be able to just download a file and never interact with the print dialog at all. Saves so much time, especially when printing to different printers let alone using different settings on the same printer.

Now that macOS supports Shortcuts, at some point I will likely convert this setup to process the files via Shortcuts rather than Hazel. But the overall process will still be very similar, especially the shell script code.

@george_c Did you ever get this working with Shortcuts? It works great for me in Hazel, but I also wanted to have a Shortcut that lets me send the file to print via the Finder Quick Actions menu. However, I keep getting an error when running.

I assume this is me not fully knowing how to properly connect a Run Shell Script action in Shortcuts, which is why I tried getting the path via a variable, but it still doesn’t work.

I did start building these out in macOS Shortcuts. I will dig into the workflows when I am back at the Mac next week.

I am still currently using Hazel, mostly because it was a lot of work converting the rules to Shortcuts.

I read somewhere that Shortcuts is getting a new feature that should simplify what we currently have to accomplish with nested If/Then workflows. That might make it easier to convert these printing workflows.

OK so I do not recall if this ran properly/successfully, but here is the automation I was working with in Shortcuts.

I have a vague sense that this does indeed work, and that all that remained was to re-configure all the “rules” in a Shortcut automation in order for the proper files to be processed.

I know I was using the Folder Actions feature to automate stuff. So, I would save a file to a folder, Folder Actions would detect it, and run an automation. The rules of the automation determined which next automation to process the file with; in this case, run the printing shell script.

I may have some time later today to dig back into this and test. I put it all on hold because building Shortcut automations for all my Hazel rules was going to be a big task. Wanted to make sure the end task (printing via shell script) was even possible first.