How to open the sidebar finder folder using AppleScript?

I have a bash script that will run on a Mac via ssh. The script requires that a specific network drive is already installed. On a Mac, I mount this drive by opening the “JPLemme” folder on this drive in Finder. This installs the drive until the Mac falls asleep at night.

Obviously the Finder is not accessible via ssh, so I want to create an AppleScript that will mimic what I am doing with the GUI. I tried:

tell application "Finder" activate open "JPLemme" end tell 

I get the following error:

 execution error: Finder got an error: Can't get "JPLemme". (-1728) 

I guess I missed something obvious, but Google let me down. I would also like to make better decisions, such as installing the drive directly; I avoided this approach because I do not want the Mac to suffocate when trying to mount the drive a second time after I mounted it in an unexpected way. (I don't like Mac or AppleScript ...)

+4
source share
2 answers

Your network volume must have a domain attached to it. So, "JPLemme.domain.com". I use the following code snippet to access a network volume that is password protected:

  tell application "Finder" try set theServer to mount volume "smb://path/to/volume" as username "YourUserName" with password "YourPassword" --Please note here that this is a plain string without any built-in security. Use at your own risk. on error set VolumeCount to (get count of disks) repeat with x from 1 to VolumeCount set thisVolume to disk x if name of thisVolume is "JPLemme" then set theServer to thisVolume exit repeat end if end repeat end try end tell 

You can clean it as needed, but this is the core. Good luck.

+2
source

He has a very basic, all that is really necessary is the following:

 Tell Application "Finder" Mount Volume "smb://username: password@server /sub/directory" End Tell 

But what is being used will largely depend on the network environment and the errors returned.

+1
source

All Articles