Can it really be true that KBM does not have an action to mount a network volume?

I never noticed this gaping omission until I needed it, right now. Please tell me I’m just being stupid and overlooking it. Thanks.

You can use the Open URL action to mount a network volume, eg

Open URL afp://server.com

Thank you sir. I did try that, but I see now something I may have overlooked before: After pasting my URL, the text “Open URL” to the left of the box is in that red font that means it doesn’t like something I entered. This probably explains why, when I tried earlier, the action would open the example URL. I wonder what the problem is. My URL is of the general form protocol://username:password@host/path to mountpoint , namely afp://temp:temp@LESLIEs-iMac.local/Macintosh HD/Users/temp/Desktop, which, I hasten to point out, mounts the nwtwork volume when entered in the FInder. Thanks for your help.

The URL has to be valid as far as NSURL is concerned. The fact that the Finder (or whatever) is more lenient about URLs doesn’t change whether the URL is in fact valid.

This one is invalid as it has an unencoded space in it. Replace the space with %20 (and encode any other invalid characters) and see if that helps.

Hey Parker,

There’s a KM Action for that:

Filter Clipboard with Percent Encode for URL

-ccs

1 Like

I use Execute AppleScript with the following. You would need to edit the SERVER_IP_ADDRESS and the VOLUME# names. Also afp vs smb if you need to. The delay and repeat sections check to make sure the server is available before attempting to mount the listed volumes.

tell application "Finder"
delay 10

try
-- Check if SERVER is available
set max_retry to 10
set k to 0
repeat while (do shell script "ping -c 1 SERVER_IP_ADDRESS") contains "100% packet loss"
delay 5
set k to k + 1
if k > max_retry then error "Server is not responding for predefined period." number 8000
end repeat

-- Mount volumes
mount volume "smb://VOLUME1"
mount volume "smb://VOLUME2"

-- Error handler
on error errs number errn
-- display dialog errs & " " & errn with icon 2
-- display notification "SERVER not responding to ping."

end try
end tell

Thanks for that script shovland42! Quick question that relates to this thread (or at least I hope it doesn’t deserve it’s own thread.) I am working on a KM macro that will copy a folder containing images and paste it onto a local server. Is there a quick way to check if the server exists (is mounted), and then if not, to run the script to mount the server?


This script works good if you have many to mount, this checks if drives are mounted first. I find that afp works much better than smb.


try
set networkDisks to text 2 thru -2 of "
afp://192.168.2.101/Drive A
afp://192.168.2.101/DriveB
afp://192.168.2.101/Drive a1 b2
afp://192.168.2.101/My Documents
"

tell application "Finder" to set diskNameList to name of disks
set AppleScript's text item delimiters to "/"
repeat with i in paragraphs of networkDisks
set {diskAddress, diskName} to {contents, last text item} of i
if diskName is not in diskNameList then
mount volume diskAddress as user name "YourUserName" with password "YourPassword"
display notification diskName & " Mounted"
end if
end repeat
display notification "All Drives mounted" with title "Success Drives mounted"
return "Success"

on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell current application to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy" then set the clipboard to e
end try
end if
end try