Here is an alternative derived from the accepted answer. Indeed the accepted solution by @jnovack just opens VS Code for me, but not the desired folder. If VS Code is already running it just switches the focus to a running instance of VS Code.
Solution
Provided that you have the code CLI command installed (if not, go to VS Code and do CMD+SHIT+P>"Shell Command: install 'code' in PATH")
Then open a terminal and run which code. You should get the code executable path looking somethin like /usr/local/bin/code
Then, as per @jnovack 's answer,
- Open Automator
- Create a new Document (
CMD+N) - Create a new Quick Action
- Workflow receives current files and folders from Finder.
- Add a new Run Shell Script action to the workflow. (drag and drop the "Run Shell Script" object)
- Pass input as arguments
- Paste this code in the shell command field
/usr/local/bin/code -n "$*" or replace with your path to the code executable if it differs from this one. - Save the action
Tbh. I would have expected to be able to use just code -n "$*", but for some reason, the PATH used by the automator's shell seems to be different from that used in the terminal. I'd welcome some input on that matter.