Today I've been hacking AppleScript to make it easier for my wife to back up her work from her Mac to our Windows box. Despite all the English-like syntax, I managed to make a new folder on the Windows drive with the date in the name, and copy her important folder into it. But I'm stumped on how to get the Windows drive connected in the first place.

When I use the Record command in Script Editor, and then manually connect the drive, I get code like this:

set target of Finder window 1 to item "Network"
set target of Finder window 1 to folder "MyStreet" of item "Network" of startup disk
set target of Finder window 1 to disk "C"
set target of Finder window 1 to folder "sue" of disk "C"

I'm willing to leave aside the odd repetitive nature of these lines (why does line 2 redo what was done on line 1?) When I run this code while the network drive is already connected, it works fine. But if I run it when the drive is disconnected (which is when I need it), it fails at the third line, which is just where the UI pops up a box title "SMB Mount".

Does anyone know how to do this? Searching Google is proving fruitless. Help!

tagged: , , » 2 reactions

Comments

[gravatar]
Omer Trajman 8:45 PM on 18 Jul 2004

On OS X, due to it's unix heritage, remote SMB drives need to be mounted using mount_smbfs before the finder layer can see it. Take a look at man mount_smbfs.

[gravatar]
Ned Batchelder 6:31 PM on 26 Jul 2004

Turns out it's as simple as:

mount volume "smb://computer/drive"

though I couldn't find any mention of the command in the Finder applescript dictionary!

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.