My default PDF App is Preview. Now, I have one folder (with sub-folders in it) with PDFs that I would like to have to open all the time with another program. So basically I need to put a "Default program" for a restricted path. Unfortunately the "Always open…" is not an option (even if it would work), because the documents in this folder change pretty often.

Does someone know if Automator or AppleScript may help me with this?

2 Answers 2


Using Finder for file management?

Drag your program of choice into the toolbar and drop it there:

Add a file or an app: Press and hold the Command key, then drag the item to the Finder toolbar until you see a green plus sign.

Now double click on a PDF will open the PDF still in Preview.

You can select your other PDFs and then drop them on the Toolbar icon for the program of your choice.

Using a more programmery way would be to make an alias to

open -a YourAlternativePDFViwer.app 

Then you type in Terminal your alias, drag&drop all your special PDFs on the Terminal. Terminal then expands all the paths to your PDFs and upon hitting Enter your preferred viewer should open all those PDFs.

Even easier would be an alias that reads as follows:

open -a YourAlternativePDFViwer.app /path/to/your/SpecialtyPDFS/*.pdf

If more automation is required, then you might have a look into Folder Actions Reference.

For double-clicking AFAIK it's either one or the other. But depending on special filetype characteristics RCDefaultApp might be worth a look.


If you save this following script to your /Users/your username/Library/Workflows/Applications/Folder Actions folder, it will be available to select in the folder actions set up dialogue. Then every time you add a PDF file to the designated folder, it will set the default application to which ever PDF viewer you assigned in the script.

I rearranged the script a little bit to make it a bit more universal. Now it's easier to tweak the code to work with different file extensions and different applications, just by changing the property values while leaving the body of the script completely intact.

This version will target ONLY THE PDF'S, no matter what type of file gets added to the folder

property Default_App_To_Open_With1 : alias "Macintosh HD:Applications:Adobe Acrobat Reader DC.app:"
property Default_App_To_Open_With2 : alias "Macintosh HD:Applications:TextEdit.app:"
property Default_App_To_Open_With3 : alias "Macintosh HD:Applications:Preview.app:"

property Default_App : Default_App_To_Open_With2

property name_Extension : "pdf"

on adding folder items to this_folder after receiving dropped_items
    repeat with this_File in dropped_items
        tell application "System Events"
            if name extension of this_File is name_Extension then
                set default application of this_File to Default_App
            end if
        end tell
    end repeat
end adding folder items to
  • 1
    I typically just use the macOS default for PDF's which of course is Preview, however I do have a few different folders in which I've always opened the PDFs in Skim, albeit manually. I just implemented your solution on those particular folders, while empty and then added the PDFs back to them. Nice answer! +1 Oct 20, 2017 at 21:22
  • 1
    BTW I've recoded the code in my implementation of your answer as it changed the date/time stamps and in the process found you do not need any of the open for access ... and relate code. set default application ... works by itself without any of that. Oct 21, 2017 at 3:03
  • Really? That's odd because I believe the reason I put “Open For Access” and its related code, was in an attempt troubleshoot, some errors the script was throwing. HMM… I guess it was something else that I had changed which was throwing the errors LOL thanks for the heads-up. Actually now that I think about it, I believe initially I had "Finder" trying to set the default application, Instead of system events... If I recall correctly, The "open for access" Was part of the initial "Finder" code I was working on, and it seemed to work so I just left that part of the code in there
    – wch1zpink
    Oct 21, 2017 at 3:17
  • FWIW, Here's what my folder action handler looks like: paste.ee/p/VRZlX Oct 21, 2017 at 4:58
  • 1
    When I originally setup the folder action with your original code, it changed the modification date/time stamp on the files and I do not want the modification date/time stamp changed from the creation date unless the actual contents of the file internally changes, not the xattr attributes. So using GetFileInfo I get the creation date and then use SetFile to set the modification date to the creation date as that's what they were before the folder action. GetFileInfo and SetFile are a part of Command Line Tools for Xcode. Oct 21, 2017 at 6:12

You must log in to answer this question.

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