Should I use Folder Actions in 2023/24?

I want to setup an automation where a Python script – which I already wrote and which works manually fine – runs every time a new PDF file appears in an iCloud folder. (That script uses PyPDF2 to extract text from the PDF and, no, the Automator action “Extract PDF text” is no option because it doesn’t work correctly for my PDF files.)

How should I setup the automation?
I know about macOS’s Folder Actions and experimented with that but wasn’t successful, yet.
I could setup a cron job, of course, that runs every 5 minutes or once an hour … but I consider this only a “meh” solution because I actually wnat to use the trigger that a new file appeared in that iCloud folder. (btw, the file gets created by a Siri Shortcuts workflow in my iPhone.)

macOS Folder Actions are rather old but are still there in macOS. Are they reliable? Even for iCloud folders? Should I follow that path? Should I put my whole Python 3 script inside a “Run Shell Script” action in the Automator workflow? I haven’t found a way to debug this, yet. I checked the “Show this action when the workflow runs” checkbox and at least THIS seems to work. But I get no feedback at all if the Python script inside the action works at all, despite several print statements … nothin in the “Results” tab :man_shrugging: And I can’t test it directly inside Automator because then I don’t get the filename as input. (I selected “Pass input as arguments” and use argv inside my Python script.)

Anyway … Any thought on this topic? Any experience I could build on? Any other options besides macOS’s Folder Actions and a (rather dumb) cron job?

Thanks so much & cheers,
Stefan.

Sounds like something Hazel could handle. There is a free trial.

2 Likes

Hmmm … Or Alfred?

But … these will only work if a Mac is always on and running, right? Pure client-side tools, no?

On the other hand … a cronjob needs an up & running computer, too. :joy:

And a Folder Action on an iCloud folder? iCloud is “always on” … :thinking:

Ah, well, I do have a Mac mini always on. Thanks for the tipp, @MevetS! :blush: I’ll investigate!

1 Like