Change download location of Safari PDF download button

I would like the following behaviour of the Safari PDF Download button:

On clicking the PDF download button by moving the pointer to the bottom of a pdf/ps, the file is downloaded to the Downloads/ folder. Instead, I would like that to work as a "Save As" button so that I can save the pdf by a different name and in a location I prefer.

I know there is Cmd-S but I would like to use this as an opportunity to learn about Apple Scripts if that kind of idea can be used to solve this problem.


Solution 1:

AppleScript on its own can't be used to 'hook' into other actions such as clicking certain things. There are tools available to run AppleScript on keyboard shortcuts, however you might as well use ⌘S in this case, or remap this shortcut with System Preferences → Keyboard. One cannot change the download location of the button in Safari preferences.

Solution 2:

You will not be able to intercept the clicking action of a button using Applescript.

There are a couple of approaches you can use to achieve your goal.

1, Create an Automator Folder action to watch for pdfs file in the downloads folder. And Ask you where you want to move them.

2, Write an applescript that runs from the Applescript Menu or a Automator Service ...

Using the Applescript Approach I would get the url of the front window of Safari.

And then have my applescript ask me to choose where to save it.

For the downloading you may have to use some shell scripting like Curl in aApplescript Do shell script command.

Look at the Safari Scripting Library for details on accessing the url.

You can find out more about applescript and how to use it by looking at the Introduction to AppleScript Language Guide