There is a Server field in the Get Info Dialog as illustrated below:
Is there a way to assign it to a variable in Applescript?
I have written a script as following:
tell application "System Events"
set disk_list to the server of disks
repeat with a_disk in disk_list
display dialog a_disk
end repeat
end tell
All the dialogs show "msng". 😅
The only method I can think of is illustrated in the code below, with the caveat that I do not have a wide range of network drives or servers with which to test how effective or reliable it is at returning the desired path. In fact, I've only managed to test it in the context of the one use case that I could create for myself: I shared my iMac's ~/Music
folder as a samba folder share, which I mounted at /Volumes/Music
on my MacBook.
use framework "Foundation"
use scripting additions
-------------------------------------------------------------------------
property key : "NSURLVolumeURLForRemountingKey"
-------------------------------------------------------------------------
to resolveURLForFile at path as text
global key
tell the resourceValuesForKeys_error_([key], missing value) ¬
of the fileURLWithPath_(stringByStandardizingPath() ¬
of my (NSString's stringWithString:path)) of my the ¬
NSURL to tell ([] & it & missing value)'s beginning ¬
to if it is not missing value then return "" & (the ¬
absoluteString())
false
end resolveURLForFile
---------------------------------------------------------------------⟨!#⟩
My test was run as follows:
resolveURLForFile at "/Volumes/Music"
for which the returned output was:
"smb://CK@CK-mac._smb._tcp.local/Music"
If it is unable to resolve a path, then it returns false
.