Add script to right click menu


I’ve been making a concerted effort to add some automation in my life recently and have binged about 20 episodes of the podcast.

With that in mind, I’m stuck and hoping someone can help:

Short version:
Does anyone know if there a way that I can add a nodejs script to the right click menu when I click on a folder and it then pass the directory path into the script as the first command line arg?

Longer version:
I post a lot on Instagram and have written a script to loop through a directory of .txt files and if they have -readyForTags in the file name it will append a selection of hashtags to the file along with some other sign off text I use for my posts, it will then replace -readyForTags with -tagged and rename the file.

This saves me a lot of time but I have to run it in the terminal and pass the directory in as a command line arg, hence wondering if I can change it to a right click :grinning:

Any help would be amazing, I have a SetApp subscription as well so have access to all those apps (thanks for the Automators code for the extended trial)

I think Service Station would be able to do this.

You can also create a “Service” , which is now called “quick action” I believe, inside automator, and include “run shell script” as action. In the shell window you can choose to send the files and folders as standard input or as parameters.
I generally pass them as parameters and then use a script like this:

for f in $@
	touch "$f"

Obviously replace “touch” with whatever command you need to run on the files.

Screenshot 2022-08-16 at 12.18.13

1 Like

Thanks for these suggestions. Sadly I can’t make heads nor tails of how Service Station works and the quick action isn’t working and I can’t work out where to find logs for it when I run it.

The main issue with the automator action is that when run in that environment it doesn’t have access to node

Ok! Problem solved, I added this line to the start of the run shell script action and it then had access to node and works perfectly.

export PATH=$PATH:/usr/local/git/bin:/usr/local/bin

Thanks again!

It might be nice to give @esoel’s post a little :heart: given that it worked perfectly; and helpful for other forum users to mark the post as having solved your problem. It’ll help others who may have the same or a similar issue in the future.

Sure thing, added a :heart: I can’t see a way to mark the answer as a solution though, I can like it, link it, bookmark it and reply to it but not mark as solution