Get Sub-Folder Name without opening finder window?

Hey Guys,

In general it’s better to avoid Finder-references completely.

If you know you’ll always have ONLY 1 subfolder then this is a bit more efficient:

set folderAlias to alias ((path to downloads folder as text) & "temp:")

tell application "Finder"
   set subFolderPath to folders of folderAlias as text
end tell

I recommend never using the SystemUIServer for this purpose.

tell application "SystemUIServer" 
    set parentFolderAlias to (choose folder with prompt "Choose PARENT Folder")
  end tell

You leave the user HANGING in it, and they have to click out or or switch apps to get back to where they started.

Since there’s no indication to the user that they’ve switched apps (to the SUIS) this can be very disconcerting.

The best way to handle this is to work with the frontmost application like so:

set frontApp to path to frontmost application as text

tell application frontApp
   set myFolder to choose folder
end tell

This method will drop the user right back where they started and avoid confusion.

-Chris

1 Like