Archive for the ‘Automation’ Category

Default Folder X: Opening folders in Path Finder vs. Finder

Wednesday, June 2nd, 2021

With the recent focus on Default Folder X’s integration with Path Finder, I’ve been fielding a number of questions about how to make Default Folder X open folders in Path Finder instead of the Finder.

Using Path Finder instead of the Finder for all apps

The first, simplest answer is that Default Folder X uses your “default file browser” when opening folders. If you set your default file browser to be Path Finder, selecting a folder from Default Folder X’s menus will open it in Path Finder. This will also make all other apps on your Mac use Path Finder for their “Reveal in Finder” commands.

“But how the heck do I set Path Finder as my default file browser?” you say. Well, I’m glad you asked! It’s easy – there’s a setting in your Path Finder preferences:

Turn on this checkbox and you’re done.

Using Path Finder instead of the Finder – but just for Default Folder X

If you’d rather make this apply only to Default Folder X, you can set Default Folder X’s “fileViewer” preference in Terminal with this command:

defaults write com.stclairsoft.DefaultFolderX5 fileViewer com.cocoatech.PathFinder

Note that if you’re using the Setapp version of Path Finder, you should replace ‘com.cocoatech.PathFinder’ with ‘com.cocoatech.PathFinder-setapp’. To tell Default Folder X to go back to using the Finder instead of Path Finder, just replace ‘com.cocoatech.PathFinder’ with ‘com.apple.finder’.

Toggling between Path Finder and Finder on the fly

And finally, if you want to get really fancy and sometimes have Default Folder X open folders in the Finder and sometimes in Path Finder, you can set up an AppleScript to toggle back and forth. Attaching a script like this to a keyboard shortcut using Peter Lewis’ amazing Keyboard Maestro app makes it super-easy:

-- set the 'currentViewer' variable to the current fileViewer setting
set currentViewer to do shell script "defaults read com.stclairsoft.DefaultFolderX5 fileViewer"
-- now switch to whichever fileViewer is currently not in use
if currentViewer is "com.apple.finder" then
do shell script "defaults write com.stclairsoft.DefaultFolderX5 fileViewer com.cocoatech.PathFinder"
else
do shell script "defaults write com.stclairsoft.DefaultFolderX5 fileViewer com.apple.finder"
end if

Automatically prepending dates to the names of saved files

Wednesday, September 9th, 2020

So a Default Folder X user just emailed and asked this:

I have been a Mac user for 30 years and would love to find a tool that allows me to click a button (or make this the default filename) while in the “Save…” dialog box that will prepend a formatted date to the beginning of the filename. like so:

2020-09-08 Filename.ext

Now, you can set up an AppleScript to do this using Default Folder X’s GetSaveName and SetSaveName verbs. However, that would require that you run the AppleScript whenever you want the date prepended, which is a bit of a pain if you want all of your filenames formatted this way. But I realized as I was replying that you can actually automate this by using (or rather, slightly abusing) an existing feature in Default Folder X.

Default Folder X has the ability to run an AppleScript to determine the location of an application’s default folder. The script will be run whenever a new file dialog is displayed by an application, which is the perfect time to do our little filename modification. So I wrote an AppleScript that looks like this:

on getDefaultFolder(appName, dialogType, firstTime)

  -- only do this for save dialogs
  if dialogType is "save" then

    -- get the current date
    set dateObj to (current date)

    -- then format it as YYYY-MM-DD
    set theMonth to text -1 thru -2 of ("0" & (month of dateObj as number))
    set theDay to text -1 thru -2 of ("0" & day of dateObj)
    set theYear to year of dateObj
    set dateStamp to "" & theYear & "-" & theMonth & "-" & theDay

    -- then prepend that to the name in the save dialog
    tell application "Default Folder X"
      set theName to GetSaveName
      set theName to dateStamp & " " & theName
      SetSaveName theName
    end tell
  end if

  -- finally, don't give Default Folder X a default
  -- folder, so it just continues on normally 
  return ""
end getDefaultFolder

If you save this script in a file named “GetDefaultFolder.scpt” in this location:

~/Library/Application Support/com.stclairsoft.DefaultFolderX5/Scripts/

It will magically prepend the date in the format ‘2020-09-15’ to the beginning of all of your filenames in Save As dialogs. Note that you can still edit the name afterwards if the default filename (like “Untitled 4”) needs to be modified.

App Tamer 2.5.1 adds more AppleScript support, fixes issues

Monday, May 18th, 2020

Version 2.5.1 of App Tamer is available now. Among other things, it includes fixes for a couple of complaints with the “using too much CPU” notifications that App Tamer puts up when a process is – you guessed it – using too much CPU. It will no longer notify you if you’ve already throttled an app, even if the app is still over the warning threshold. It also provides a method of making the “Let it continue” button suppress the high-CPU notifications for longer. The default is now 10 minutes (instead of 5) before you see another warning, and you can change that by using this command in Terminal:

defaults write com.stclairsoft.AppTamer notificationMuteTime XXX

where XXX is is the number of seconds to silence notifications.

And for those folks that want to automate control of their apps, a new “manage” verb in App Tamer’s AppleScript dictionary lets you create scripts so you can change settings on a schedule, change an app’s settings with a keyboard shortcut, or something AppleScript-y like that. Here’s an example:

tell application "App Tamer"
manage "Safari" slow yes slowCPU 2 hide yes hideDelay 10
end tell

That will slow Safari to 2% CPU usage when it’s in the background and will hide it after it’s been idle for 10 minutes. To see all of the options, open App Tamer’s dictionary in Script Editor.

This scripting ability is being used by some users to change settings for backups so they run with different CPU limits at night vs. during the day, and throttling background apps more aggressively during video calls. As they say, the possibilities are endless!

App Tamer 2.5.1 also includes a number of fixes for infrequently encountered bugs, such as incorrect behavior when the stats update frequency is set to “never”, and processes not appearing when they’re run from the Terminal using ‘sudo’ or ‘su’.

For a full list of changes and download links, visit the App Tamer release page.

Default Folder X 5.4.3: Better performance, better previews, and a bunch of fixes.

Friday, March 6th, 2020

Version 5.4.3 of Default Folder X, our app for managing files and folders in Open and Save dialogs and the Finder, is now available. This release speeds things up when opening items in the Finder, ForkLift and Path Finder, as well as when saving files to slow servers over a network. It also brings little improvements in several areas:

  • The on-the-fly previews (the ones you see when traversing Default Folder X’s menus, in its Finder drawer, and in Open dialogs) have been improved to look better and display more smoothly.
  • It’s now easy to make Default Folder X forget all of your recently used files, folders and Finder windows all at once. Just hold down the Option key when choosing “Forget Recent <whatever>” at the bottom of a menu, and the menu command will change to “Forget All Recent Data”.
  • For any AppleScripters out there, there are new commands for managing files and folders in DFX’s Finder drawer, and an option to pop up its menu at a specific screen location. Note that if you’re using a macro utility that can run AppleScripts (like Peter Lewis’ excellent Keyboard Maestro), this can make it really handy to get to Default Folder X’s menus without going up to the menu bar.

There are also more than a dozen bug fixes, covering everything from occasional reliability issues to more esoteric problems with Pro Tools, Rogue Amoeba’s Fission app, and the built in screen capture utility in Mojave and Catalina. Oh, and Default Folder X’s Finder-click feature will now recognize all the tabs in Finder windows that aren’t in the current Space (if you’re using Mission Control to manage multiple workspaces). That was a really weird one.

Itemized release notes with all the details are available on the Default Folder X Release page, as usual, along with download links.

Default Folder 5.4 for Catalina, with Path Finder SetApp support, improvements for scripters and more

Monday, October 7th, 2019

I’m happy to announce that the final version 5.4 of Default Folder X is now available. Thank you to everyone who beta tested the pre-release versions and reported issues!

The marquee feature of this release is, of course, support for macOS 10.15 Catalina, which Apple should drop any day now. In addition, there are a couple of new AppleScript commands in Default Folder X’s scripting dictionary to help scripters automate the handling of file dialogs (and don’t forget the scriptable default folders too). This version also adds support for the version of Path Finder distributed via SetApp.

Finally, there are a handful of bug fixes, including corrections for issues with Finder windows, adding new Favorites, and Accessibility quirks. These fixes apply to both Catalina and earlier macOS versions – if you’re running an older version of macOS, you can still update to Default Folder X 5.4. It supports anything from macOS 10.10 to 10.15.

The update is free if you’ve already got a license for Default Folder X 5 – just choose “Check for Updates” from Default Folder X’s menu, or download a copy here. A list of changes and download links, including localized versions, are available on the Default Folder X release page.

Default Folder X: Using AppleScript to specify default folders on the fly

Tuesday, May 28th, 2019

Version 5.3.7 of Default Folder X introduced a new capability: it can now ask what the default folder for an application should be on the fly using AppleScript. That may sound like a mouthful of jargon, so let me explain, because it can be applied in a lot of situations.

Jason Snell (of Six Colors and The Incomparable fame) has been writing about Macs forever, and is now a prolific podcaster. He emailed to ask if it would be possible to make Default Folder X more flexible. At that time, you could set a default folder for an application so that when you chose Save As, it always offered to save a file in that particular folder. His problem was that you have to set a single folder as the app’s default folder – just one.

Jason creates podcasts – lots of them. His reasoning was that if he could magically tell Default Folder X what podcast he was working on, it would always offer to save the component audio files into the folder for that podcast. Essentially: Wouldn’t it be great if you could edit an audio clip, hit Save, and have it automatically go into the folder for the current podcast folder? No re-configuring a default folder for each new project – it’d just work.

So he hit on this idea (which I think is just brilliant). He uses Apple’s Logic X application to create his podcasts. So for each podcast episode, there’s one master Logic X project file. To find the correct default folder for audio clips, all he has to do is look at all the project files and see which one has been saved most recently. The “Audio Files” folder sitting next to that project is where everything should go for the current project. He wrote an AppleScript to do this, which he shared on the Six Colors blog.

This can obviously translate to all sorts of different workflows. If you have one primary file for each project, it’s easy to tell which one you’re currently working on – it’s the one that’s been saved most recently.

How to set up an AppleScript to specify a default folder

So how do you wire up Default Folder X to do this? It’s pretty simple. Put an AppleScript script in:

~/Library/Application Support/com.stclairsoft.DefaultFolderX5/Scripts/

or, if you want it to handle only a single application, put it in a sub-folder of the Scripts folder named for the application you want it to serve. To have it queried only for Preview, for example, put an AppleScript in:

~/Library/Application Support/com.stclairsoft.DefaultFolderX5/Scripts/Preview/

Download this example script file to see what you need to do in your AppleScript script:

http://www.stclairsoft.com/download/GetDefaultFolder.zip

The trick is that you need to implement this handler:

on getDefaultFolder(appName, dialogType, firstTime) 

which returns the location of the default folder. Open up the sample script file in Script Editor (or your AppleScript editor of choice) and have a look. I’ve tried to explain things clearly in the comment at the top, and the script shows a number of different ways of returning folders to Default Folder X. And of course, you can also use Jason’s complete script as a starting point.

I think Jason’s idea is great – it streamlines work on multiple projects, but most importantly, it reduces the chance for error as you’re trying to meet that pressing deadline. I’d love to hear how others use this feature, so please drop me a line if it works for you too!

Default Folder X 5.3.7 updates Finder window tracking, shows additional metadata and more

Thursday, May 16th, 2019

Default Folder X 5.3.7 is now available, and it displays a couple of additional pieces of metadata in the Info panel below Open dialogs, most notably the “last opened” date. It also addresses a number of issues, including problems with LaunchBar, sub-par behavior when file dialogs are very large or lie partially off-screen, keyboard shortcuts not working after using a menu bar app, and drag-and-drop problems with the Finder drawer. A full list of changes is available on the Default Folder X Release page or in the Version History.

This version also works around bugs in Mojave that have been affecting Default Folder X’s ability to list open Finder windows when those windows contain multiple tabs. It will now list those windows reliably, but may still get confused and show some tabs as being in their own, separate windows – but hey, at least they’re all there, right? Unfortunately, a complete solution requires that Apple fix the bugs that I’ve submitted.

And one very important note about Finder windows: The behavior of Default Folder X’s Finder-click feature has changed a bit. Most people won’t be affected by this, but if you have been relying on the fact that Finder-click showed windows that weren’t actually visible (because they’re in another Space or because the Finder’s hidden), you’ll find that they’re no longer appearing. They’re still in the Finder Windows menu in Default Folder X’s toolbar, or you can revert to the old behavior by following these instructions.

Finally, on the truly geeky side, you can now create an AppleScript to supply Default Folder X with a default folder for an application on the fly. When a file dialog comes up, DFX will run your AppleScript, and if it returns a folder, that’ll be used as the default folder for that file dialog. It works seamlessly and can really simplify things if you work in a project-based manner with a consistent way of determining where your project folder is. Look for a blog post about this shortly.