I use the following AppleScript script to automatically connect a remote drive when my VPN connection is established using Viscosity:

do shell script "sleep 5"
tell application "Finder"
    mount volume "smb://some.domain.here/projects"
end tell

This works ok. However this does not read the contents of the folder. So when I go to this folder for the first time, it takes extra 30 seconds to retrieve the list of files and folders.

Is there a way to tell Finder to pre-load the content of this network (!) folder in the background, without activation (it is ok to change Finder's folder to /Volumes/projects)? I tried to get a list of files into a variable. I get file names in the variable but the Finder window still tries to pull files again. I tried to "ls /Volumes/projects" but the Finder stills loads files on its own.

The folder is read-only.

  • Any particular reason why you’re not just telling Finder to open the newly mounted folder in a window at the end of the script? That won’t get you around the delay (that one is courtesy of Apple’s new SMB stack, it seems), but if you don’t jump to that folder right after connecting, you have essentially preloaded it. Also, no need to resort to the shell for sleep – AppleScript has a delay command. – kopischke Jan 28 '13 at 15:15
  • Thanks for the "delay" hint. The connection is slow. I usually select to connect and continue working. The goal is to connect and preload the content of the folder in the background, without flashing Finder on top of other windows. – Unnamed_1 Jan 28 '13 at 17:18

You must log in to answer this question.

Browse other questions tagged .