Default Folder X

I am trying to get this AppleScript to work

tell application "Default Folder X"
   delay 2
   SwitchToFolder POSIX file "/Volumes/xxx.xxx.xxx.xxx/Test Name/"
end tell

Have reached out to Jon at St. Clair Software but does anyone have any ideas on this?

The volume is WebDAV mounted.

What I am trying to achieve. Users access this WebDAV volume. When saving a Preview file need to jump to the correct folder on mounted drive.

I have created a work around by using AS script to access Default Folder X Favourites but this relies on correct ordering of the folders and is not exportable without having to recreate Favourites on each individual Mac.

Here you go

Hey Michael,

I don't have a WebDAV server to test with at the moment, but try this format:

tell application "Default Folder X"
   SwitchToFolder "/Volumes/YourVolume/"
end tell

No posix file...

-Chris

Got error message in log file:

2023-01-10 17:37:49 Execute an AppleScript failed with script error: text-script:208:217: execution error: The variable theFolder is not defined. (-2753). Macro “GoTo Specified Folder” cancelled (while executing Execute AppleScript).

But might have been just me not getting addressing correctly. As all I did was delete line
set theFolder to POSIX file GoToPath

I get confused as webdav software is Rumpus and serves on /Shared/ folder but when mounting just shows as IP address and then contents.

/Volumes/77.103.226.111/2017

Screen Shot 2023-01-10 at 17.40.07

Hmm...

Okay, run this from the Apple Script Editor.app:

tell application "Finder"
   open "/Volumes/77.103.226.111/2017" as «class furl»
end tell

The WebDAV volume must be mounted of course.

Let me know if it works.

error "Finder got an error: Handler can’t handle objects of this class." number -10010

Run this, and tell me what you get:

tell application "Finder"
   set diskList to disks
   repeat with theDisk in diskList
      set contents of theDisk to (contents of theDisk) as alias
   end repeat
   
   diskList
   
end tell

{alias "77.103.226.111:", alias "App Tamer:", alias "Blank Drive:", alias "SSD Drive 1:", alias "home:", alias "net:", alias "VM:"}

You didn't actually use the path in your script -- you set it in KM, "imported" it into the AppleScript, but used a different value for SwitchToFolder.

I don't have Default Folder X, but the examples on their website separate setting the path from calling SwitchToFolder. It shouldn't make a difference, but you could try setting an explicit file object by changing the AppleScript in your last macro to:

set inst to system attribute "KMINSTANCE"
tell application "Keyboard Maestro Engine"
   set goToPath to get variable "Local__GoToPath" -- I'm assuming 2 underscores in there?
end tell

set theFolder to POSIX file goToPath
tell application "Default Folder X"
   SwitchToFolder theFolder
end tell

And, unless this is part of something bigger and you earlier got (or later need) the full path, the Parent Path Filter action is unnecessary -- just use /Volumes/77.103.226.111 when you set your variable.

As with Chris's tests, make sure you're connected to the WebDav volume, but have no Finder windows open, and then try:

tell application "Finder"
   open POSIX file "/Volumes/77.103.226.111"
end tell

...in Script Editor/Script Debugger. That should pop a Finder window showing the root directory of the share, which will prove things are properly mounted/accessible.

Whups! Good catch. I missed that entirely...

Hey Michael,

Nige probably has the answer here, but if that doesn't work try this:

set webDavDiskAlias to alias "77.103.226.111:"

tell application "Default Folder X"
   SwitchToFolder webDavDiskAlias
end tell

If that works then you can flesh out the path – keeping in mind that the separators for aliases are ":" and not "/"

-Chris

Well stand alone script works fine from AS editor.

If I substitute application Default Folder X for Finder I get error Result "missing value"

Tried this below in KM:

Screen Shot 2023-01-10 at 18.38.35

and got log file message

"2023-01-10 18:54:00 Execute macro “GoTo Specified Folder” from trigger Editor
2023-01-10 18:54:00 Action 12826538 failed: Execute an AppleScript failed with script error: text-script:106:132: execution error: Keyboard Maestro Engine got an error: Can’t get variable "Local__GoToPath". (-1728)
2023-01-10 18:54:00 Execute an AppleScript failed with script error: text-script:106:132: execution error: Keyboard Maestro Engine got an error: Can’t get variable "Local__GoToPath". (-1728). Macro “GoTo Specified Folder” cancelled (while executing Execute AppleScript)."

That's my bad -- I missed out instance inst (plus autocorrect added a space -- grrr!). Line 3 should be:

set goToPath to getvariable "Local__GoToPath" instance inst

Also note -- your macro now tries to get Default Folder X to open the /Volumes folder. Why are you using a "Filter -- Parent Path" action?

This works!

Thank you everyone for help.

set webDavDiskAlias to alias "77.103.226.111:MPL New Venture Dylan"

tell application "Default Folder X"
   SwitchToFolder webDavDiskAlias
end tell
2 Likes

This works great when switching folders from the Default Fold X interface so big thanks.

set webDavDiskAlias to alias "77.103.226.111:VW Files 2023:HT H Tiddy"

tell application "Default Folder X"
  SwitchToFolder webDavDiskAlias
end tell

It does not work when the DFX dialog is not in use. The DFX Favourites menu is available but I would like to be able to switch folders using AS script in similar fashion to above solution. My original solution was to use script below to access DFX Favourites menu and then change the repeat to select correct folder. But is there a simpler way? (Folders are living on webdav mounted volume but is there a way to script so does not matter if local or mounted volume?

repeat x times
    key code 124
  end repeat
tell application "System Events"
  tell application process "Default Folder X"
    tell menu bar 2
      tell menu bar item 1
        try
          with timeout of 0.01 seconds
            perform action "AXPress"
          end timeout
        end try
      end tell
    end tell
  end tell
end tell
do shell script "killall 'System Events'"
tell application "System Events"
  repeat 6 times
    key code 125
  end repeat
  key code 124
end tell

By the way Chris - thank you for your patience! Worked out how to paste AS script. Easy peasey :slight_smile:

2 Likes

What do you mean switch folders? In what context?

Hi Chris,

In Finder, or Forklift I just want to be able to switch folders without using the DFX Favorites menu as other users are switch folders constantly.

Also, slight off topic. The original AS was part of a macro that saves email attachments to specified folders and then goes on to a Job Entry Macro.

In testing command Save does not open DFX dialog box. Tried Save as… and macros work fine but then Preview becomes completely unresponsive to mouse clicks, couldn't close the open file, and could not even quit from menu. Had to use Activity monitor which showed Preview cpu use jacking up to 99%. However, if I used Export as pdf macro runs fine and Preview works fine.

Bit weird - just mention as who knows might crop up for someone sometime in the future.

Finder is simple:

# Path-To based alias form:
set targetFolderAlias to alias ((path to downloads folder as text) & "Test Folder in Downloads:")

tell application "Finder"
   activate
   open targetFolderAlias
end tell
--------------------------------------------------------
use AppleScript version "2.4" --» Yosemite or later
use framework "Foundation"
use scripting additions
--------------------------------------------------------

# Posix Path or Home-Based (Tilde) Posix Path:
set targetFolderPath to "~/Downloads/Test Folder in Downloads/"

set targetFolderPath to ((current application's NSString's stringWithString:targetFolderPath)'s stringByExpandingTildeInPath) as text
set targetFolderAlias to alias POSIX file targetFolderPath

tell application "Finder"
   activate
   open targetFolderAlias
end tell

--------------------------------------------------------

Forklift's AppleScript dictionary is brain-dead but not entirely useless.

This script will operate on the currently selected pane.

--------------------------------------------------------
use AppleScript version "2.4" --» Yosemite or later
use framework "Foundation"
use scripting additions
--------------------------------------------------------

# Posix Path or Home-Based (Tilde) Posix Path:
set targetFolderPath to "~/Downloads/Test Folder in Downloads/"

set targetFolderPath to ((current application's NSString's stringWithString:targetFolderPath)'s stringByExpandingTildeInPath) as text
set targetFolderAlias to alias POSIX file targetFolderPath

tell application "ForkLift"
   reveal path targetFolderAlias
end tell

--------------------------------------------------------

What email client are you saving attachments from?

Thunderbird. Just don't fancy migrating as a ton of emails in there.