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? May 20, 2016 at 8:39
  • 2
    @DavidAnderson I need to open folder itself with an application not an file. May 20, 2016 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, 2016 at 15:35
  • 2
    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 May 20, 2016 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, 2016 at 19:32

6 Answers 6


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, 2021 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. Feb 19, 2021 at 14:30

The simplest solution is to create a Quick Action with Open Finder Items: This way you don't need a shell script that might break with an OS update or VS Code update

  1. Launch Automator and select Quick Action or File > New > Quick Action If Automator is already open.

Quick Action

  1. Set Quick Action receives selected to files or folders and in to Finder. Files and Folders

  2. Choose an Image (icon) select Choose.. and double click Visual Studio Code in the window that pops up, this will set your quick action icon to the same as VS Code

  3. On the left-hand side where you see all the available items to add to your automation go into the search bar and type open, next choose Open Finder Items (you can either double click it or drag it to your workflow).

  4. In the Open Finder Items section choose open with select Other.. then from the popup list select Visual Studio Code. Please see the screenshot below.

Choose VS Code as the app to open

  1. Finally just hit CMD+S to save and name it Open in VSCode

Here is your end result:


  • 4
    @fsb Well this does not use any shell scripts rather the Open Finder Items. I don't understand the downvote. My answer is universal and works on the latest version of MacOS despite the accepted answer which does not. Dec 29, 2021 at 0:30
  • 4
    I personally found this one very helpful. Thanks!
    – Andrew M.
    Feb 9, 2022 at 16:33
  • 1
    Agreed, this is a good quality answer
    – fabspro
    Apr 21, 2022 at 4:25
  • 1
    This is actually the easiest to implement answer, and from that perspective possibly the most effective. Thank you.
    – Dan Ortega
    Jun 14, 2022 at 15:31
  • 2
    The downvotes are likely due to #4. Add Open Finder Items, Choose open with as Other.. there really is no explanation for how to do that. Your screenshots do not demonstrate where that is and I certainly cannot find it. Maybe you could clarify? This looks like the best answer. (I voted up) Apr 1, 2023 at 16:23

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.

  • For VS Code, specifically: for f in "$@"; do open -a 'Visual Studio Code' "$f"; done; And save it as "Open in VS Code"
    – Paul Mel
    Dec 10, 2021 at 6:01

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


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! Jan 8, 2021 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? May 20, 2016 at 8:43

You must log in to answer this question.

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