I use and highly recommend Hazel. It's developed by another indie developer, Paul Kim, who also has a long and reliable track record.
If you want to roll your own, here are two possibilities:
-
macos - Monitor a folder for changes, and run a command when a change is detected - Ask Different
-
How to Trigger Any Action When a File or Folder Changes on Macos on the Cheap
I've tried neither, but I have used launchd (employed in the second) several times.