{"id":1014,"date":"2025-11-21T10:15:03","date_gmt":"2025-11-21T17:15:03","guid":{"rendered":"https:\/\/strawhousepig.net\/wordpress\/?p=1014"},"modified":"2026-01-19T16:06:58","modified_gmt":"2026-01-19T23:06:58","slug":"hot-folder-folder-action","status":"publish","type":"post","link":"https:\/\/strawhousepig.net\/wordpress\/2025\/11\/21\/hot-folder-folder-action\/","title":{"rendered":"Hot Folder Folder Action"},"content":{"rendered":"\n<p>Updating this with the <code>-o raw<\/code> lp option since I discovered that, without, it will default to whatever is providing default papersize. In my case US Letter. If that option does not work for you, naturally edit it out.<\/p>\n\n\n\n<pre class=\"wp-block-code scroll\"><code>(*\nstrawhousepig.net\n\nHot folder action! The jokes write themselves.\n\nTakes the name of the folder it is attached to and sends received items to the\n corresponding printer.\n\nHow to: Find a place to keep a folder that is named as the printer ID (not the name), which\n can be found using 'lpstat -v', or seen in the cups web interface, or as \"Device name\"\n in the GUI printer settings, and attach this script to it as a Folder Action. The run handler\n is here just for testing, but could be set-up to send files selected in the Finder.\n\nI keep my hot folders in a child folder of the Desktop, so it's fairly convenient to drop\n items into. If dropping isn't your bag, you could place the hot folder in ~\/Library\/PDF Services,\n or write a seperate script or workflow in PDF Services to have the best of both worlds. \n*)\n\nset send_raw to {\"C3080__hold_\"}\n\nglobal send_raw\n\non adding folder items to this_folder after receiving these_items\n\tmy do_thing(these_items, this_folder)\nend adding folder items to\n\nset this_folder to (choose folder)\nset these_items to {}\ntell application \"System Events\" to set these_items to every item of (this_folder) whose name does not start with \".\"\nmy do_thing(these_items, this_folder)\n\non do_thing(these_items, this_folder)\n\tset _this to name of (info for this_folder)\n\tif _this is in send_raw then\n\t\tset add_opts to \"-o raw \" --trailing space here\n\telse\n\t\tset add_opts to \"\"\n\tend if\n\trepeat with i in these_items\n\t\tset i to quoted form of POSIX path of (i as alias) -- Comment this and the shell scripting if you want to try the \"System Events\" route.\n\t\tset _script to \"lp \" &amp; add_opts &amp; \"-d \" &amp; _this &amp; \" \" &amp; i &amp; \" &amp;&amp; mv \" &amp; i &amp; \" ~\/.Trash\/\"\n\t\t--log _script --for debuging\n\t\tdo shell script _script\n\t\t--\t\ttell application \"System Events\" to print i with properties {target printer:name of (info for this_folder)} -- Bugged. Does not work. *smh*\n\tend repeat\n\treturn\nend do_thing<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Updating this with the -o raw lp option since I discovered that, without, it will default to whatever is providing default papersize. In my case US Letter. If that option does not work for you, naturally edit it out.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[10,24,28,33,34],"class_list":["post-1014","post","type-post","status-publish","format-standard","hentry","category-code","tag-applescript-2","tag-macos","tag-os-x","tag-script","tag-shell-script"],"_links":{"self":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/comments?post=1014"}],"version-history":[{"count":9,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1014\/revisions"}],"predecessor-version":[{"id":1120,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/1014\/revisions\/1120"}],"wp:attachment":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/media?parent=1014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/categories?post=1014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/tags?post=1014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}