Save File to a Defined Folder?

I have my macro set up to open the save dialog box, but I can't figure out how to automate it to change the destination folder. I want it to go into iCloud Drive instead of Desktop.

After you have the "Save As" dialog Open:

  1. Use Type Keystroke to send ⌘⇧G to the dialog, which will open the standard popup for folder.
    image
  2. Insert Text by Typing to type the POSIX path
  3. Use Type Keystroke to send RETURN

Questions?

Hey Bruce,

The simplest method is to:

  1. Open the dialg.
  2. Press Keystroke G
  3. Pause until Go button appears.
  4. Paste ~/Library/Mobile Documents
  5. Press Go Button.

It can be done more efficiently with UI-Scripting or Default Folder (if you own a copy), but that's a trifle more complicated.

-Chris

I recently learned there's a slightly more efficient method available for doing what @JMichaelTX (steps 1 and 2) and @ccstone (steps 2 and 3) showed. Namely, if the user is in a Save or Open dialog, there's no need to invoke the Go To Folder option with ⌘⇧G because entering the ~ character automatically displays that prompt. So in this case, once the Save dialog is open the macro can be simplified to these actions (the pauses may or may not be necessary):

Save%20to%20iCloud

Edit: Likewise, typing a / character also activates the Go To Folder option.

That's useful indeed -- but it doesn't work when the cursor is already in a text field.

-Chris

Really? I've created macros that use this since learning of the method and I tested in Preview in 10.11.6 before posting, and it's always worked for me. Perhaps the difference is that I'm invoking the command when the Name field in the Save dialog is highlighted but before the name has been changed and thus before there's a cursor showing.

I wouldn't call it more efficient -- just different.
Also, your method might run into timing problem when trying to type the entire path along with the ~.

Typing ⌘⇧G prepares the popup for any path. So I don't have to worry about the path being in a KM variable.

More importantly, ⌘⇧G has long been muscle memory. No reason to change now. :wink:

To each his own.

In the context of the original question whereby the user wants to save to a specified location, I would think eliminating Keyboard Maestro actions is more efficient. Certainly, though, in other contexts the ⌘⇧G method may be preferable.

Just tested some more.

Your'e right.

-Chris

1 Like

Good to know, @ccstone. Thank you.

At best, you're eliminating one Action. Not a material change in efficiency, IMO.

It is more important to be readable and use standard tools that are well-recognized.

What any individual chooses to do is up to him/herself.

Thanks to all for the help. I have it working! I added an Alert action since if I'm working when the macro (automatically, it's set to do so every two hours) triggers, I can accidentally goof up the action with an errant keystroke or mouse movement. The alert stops the macro until I press "Continue." That works well.

Hi Chris

Thanks for this. I want to use the macro in the same way but for a different reason. A document in Microsoft Word when opened from an email has to be saved to a physical drive - I save my documents to Onedrive. Word comes up with a duplicate button but essentially a ⌘⇧S and then ⌘⇧G with the path typed in by POSIX works.

However, my questions relate to a more efficient way. I use Default Folder - how can that be used? A script? I would love to see that.

Thanks

Andrew

Hey Andrew,

See this topic:

AppleScripting Default Folder

If you need help with the scripting let me know.

-Chris

Hi Chris

Thanks for your help.

I looked at your handlers - where do they go? Can they put in a Global place and then called from an Applescript or do they need to be in the actual Applescript?

Thanks

Andrew

Hey Andrew,

Either/or.

https://developer.apple.com/videos/play/wwdc2013/416/

Or you can break the code up and not use handlers at all.

-Chris