Is it possible to add a service to a folder so as to open it with a specific application?

As shown in the screenshot below, an application named Evernote has done this. I want to do it manually for VS Code and Brackets.

enter image description here

Let's take VS Code for an example. It is a text editor that opens a folder in it and allows a user to edit the text files in the folder and its subfolders. There are so many other applications in the market like Sublime, Adobe Brackets and so on.

The folder hierarchy looks like this:

enter image description here

In order to open the folder in the app, I have to open the app, then go to the open folder option, then find the folder, then select and click on the open button.

Instead of this, I want an option in the right click menu of the folder to open the folder directly with the text editor. Just like you can open a folder in Terminal by adding a service.

  • You already can right click on a file shown in a Finder application window and open with either the default application for a different application. What do you want the service to do different? – David Anderson May 20 '16 at 8:39
  • @DavidAnderson I need to open folder itself with an application not an file. – Vikas Bansal May 20 '16 at 8:52
  • What do you expect to happen if a folder is "opened" by an application? Which application are you talking about specifically? – nohillside May 20 '16 at 15:35
  • 1
    I am talking about applications like VSCode and adobe bracket. @patrix i have even mentioned them in my question. I am a web developer and needs to open folders in these sort of text editors – Vikas Bansal May 20 '16 at 17:09
  • 1
    I'd vote to re-open, except that the clarification really makes it a 'coding' question, for Stack Overflow, rather than here. – Tetsujin May 20 '16 at 19:32

You can do this with an Automator Service.

Create the Service:

  1. Open Automator and select Service or File > New > Service If Automator is already open.

  2. Set Service receives selected to files or folders and in to Finder.

  3. Add a Run Shell Script Action, setting Shell: to /bin/bash and Pass input: to as arguments and add the following code:

for f in "$@"; do
    open -a 'Visual Studio Code' "$f"

  1. Save the Service as Open in Visual Studio Code.

enter image description here

  1. Close Automator.

You can now select Files and or Folders in Finder and then control-click (right-click) on them and select Open in Visual Studio Code from the Services Context Menu.

Note: I tested this with Visual Studio Code but not with Brackets as I don't have it installed. However you should be able to create one for it too in the same manner while substituting the application's name in the open command.

  • I did exactly this (save having to use quick action instead of service) on Big Sur but received the following error: The action “Run Shell Script” encountered an error: “The application /Users/landon/Downloads/Visual Studio Code.app cannot be opened, error=Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"” – Landon Feb 18 at 6:32
  • @Landon, Keep in mind this answer was written back in May of 2016 and things have changed considerably in macOS as far as System Preferences > Security & Privacy > Privacy settings. 1. I'd put the Visual Studio Code.app application bundle in The main Applications folder. Then try running the Automator Service/Quick Action. Hopefully that will prompt for any permission that may need to be added/checked in the aforementioned Privacy settings. – user3439894 Feb 19 at 14:30

Here is an alternative solution: instead of using the right-click menu, you could open the folder from the finder toolbar!

Please see my repo here: open-folder-with-vs-code


In macOS Mojave (10.14.2), I could not find Service option in Automator. So I had to follow the below steps to open folder contents in Preview app:

  1. Open Automator
  2. File > New
  3. Select Quick Action
  4. Click Choose
  5. Select "Workflow receives current files or folders in Finder"
  6. From the left hand side pane in Automator, drag-drop Library > Utilities > Run Shell Script into the right hand pane
  7. Ensure Pass input is set to "as arguments"
  8. Then paste the below text:
for f in "$@"; do
   open -a 'Preview' "$f"
  1. Click File > Save
  2. Give name as "Open in Preview"
  3. Go to Finder, select a folder containing PDF files, right click on folder name in finder > choose Quick Actions > Open In Preview
  4. All the PDF files should now open in Preview.

TODO: Add checks to ensure that Preview only opens some file types (e.g. PDF etc) and not binaries etc.


It does not solve the question exactly but you can always just drag the folder on to the VSCode icon in your app dock

  • Sometimes the best solutions are non-code! – Chaitanya Bapat Jan 8 at 1:19

Here there's a guide that you may use to create an application that will open your favorite applications, as well as any folders you may use frequently, so you can get to work (or play) with just a single click. Maybe it may fit your requirements :)

This workflow is used to launch Microsoft Word, Adobe Photoshop, and Apple's Preview application. The workflow also launches Safari and opens the About: Macs home page. It also opens a folder in the Finder. You could customise it as you wish.

Create the Workflow

  1. Launch Automator, located at /Applications.
  2. Select 'Application' as the type of Automator template to use.
  3. In the Library list, select 'Files & Folders.'
  4. Drag the 'Get Specified Finder Items' action to the workflow panel on the right.
  5. Click the Add button to add an application or a folder to the list of Finder Items.
  6. Click the Add button to add other items to the list, until all the items you need for your workflow are present. Don't include your default browser (in my case, Safari) in the list of Finder items. We will choose another workflow step to launch the browser to a specific URL.
  7. From the Library pane, drag the 'Open Finder Items' to the workflow pane, below the previous action.

Working with URLs in Automator​

This completes the part of the workflow that will open applications and folders. If you want your browser to open to a specific URL, do the following:

  1. In the Library pane, select Internet.
  2. Drag the 'Get Specified URLs' action to the workflow panel, below the previous action.
  3. When you add the 'Get Specified URLs' action, it includes Apple's home page as a URL to open. Select the Apple URL and click the Remove button.
  4. Click the Add button. A new item will be added to the URL list.
  5. Double-click in the Address field of the item you just added and change the URL to the one you wish to open.
  6. Repeat the above steps for each additional URL you wish to open automatically.
  7. From the Library pane, drag the 'Display Webpages' action to the workflow pane, below the previous action.

Testing the Workflow

Once you finish creating your workflow, you can test it to ensure it functions correctly by clicking the Run button in the top right corner.

Because we're creating an application, Automator will issue a warning that 'This application will not receive input when run inside Automator.' You can safely ignore this warning by clicking the OK button.

Automator will then run the workflow. Check to be sure that all of the applications opened, as well as any folders you may have included. If you wanted to open your browser to a specific page, make sure the correct page loaded.

Save the Workflow

Once you've confirmed that the workflow works as expected, you can save it as an application by clicking Automator's File menu and selecting 'Save.' Enter a name and target location for your workflow application and click Save. Follow the above process to create additional workflows, if desired.

Using the Workflow

In the previous step, you created a workflow application; now it's time to use it. The application you created works the same as any other Mac application, so you need only double-click the application to run it.

Because it works just like any other Mac application, you can also click and drag the workflow application to the Dock, or to a Finder window's sidebar or toolbar, for easy access.

  • Actually, I do not get it. How does it will add the option in the context of a folder to open the folder with an app? – Vikas Bansal May 20 '16 at 8:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .