I’ve got several applescripts written to work with files - we’ll use a simple one as an example: show in finder. The applescript gets a path to a file, which is calculated in a field in Filemaker:
tell application “FileMaker Pro Advanced”
set myFile to cell “cFinderFileName” of current record
end tell
set theFile to POSIX file myFile as alias
tell application “Finder”
activate
open container of (theFile)
select theFile
end tell
I was wondering why my scripts would work one day and not the next. I finally figured it out and here’s the problem, and it’s a dealbreaker:
The files I’m referencing are on a remote share point (Video) on a server, which mounts as a volume on the desktop. The problem is that the volume does not always mount at the same mount point:
One day, it will mount at /Volumes/Video
Another day, it will mount at /Volumes/Video 1
Another computer may mount it at /Volumes/Video 2
Either way, if the mount point changes, the scripts break!!
I know WHY this is happening: sometimes OS X will create a new mount point if a folder with the current volume name already exists in the /Volumes folder. This can happen if the computer crashes and doesn’t get a chance to clean up the /Volumes folder. There’s not much I can do about that, and I’ve seen several ‘duplicate’ folders in the /Volumes folder ie: Video, Video 1, Video 2, Video 3, etc etc., so it could potentially be anything.
I can write the script to mount the volume, (if it’s not already), that’s not a problem. The problem is where it mounts.
What I’d like to do is start off the script by first mounting the volume, then obtaining the current mount point of the volume and passing that through the script. But I can’t figure out how to obtain the volume’s current mount point. That would be the preferred method because it’s scalable to any mount point scenario.
A workaround would be to dismount the volume, delete the errant mount folder (the one that’s causing the mount point to change), then remount the volume (all via applescript or do shell command). This would force the volume to always mount at /Volumes/Video, but IMHO, it’s a messy workaround. Not only am I potentially inturrupting the user by ejecting the volume, but I’m messing with the filesystem in places I shouldn’t be messing.
Any suggestions?