Determine the original network volume name in case it's been renamed automatically due to a name conflict

On macOS, if I mount two volumes whose name is the same, the second one gets renamed, by appending "-1" to its name.

I need a method to determine the original volume name, i.e. without such a suffix. (Of course, I cannot blindly remove any "-" plus digits because the volume may actually be named like this.)

I can find the original name when using the mount command in Terminal:

//tt@192.168.61.121/NAS2 on /Volumes/NAS2 (smbfs, nodev, nosuid, mounted by tt)

//tt@QNAS%28AFP%29._afpovertcp._tcp.local/NAS2 on /Volumes/NAS2-1 (afpfs, nodev, nosuid, mounted by tt)

Here, I can tell that "/Volumes/NAS2-1" was originally named "NAS2" on the network.

How do I determine the share's name without invoking such tools, but via CF or other macOS functions, with providing the path or URL of the mounted volume (such as "/Volumes/NAS2-1")?

Accepted Reply

I found the solution myself by trial-and-error:

The NSURL resource key NSURLVolumeNameKey contains the original name. It's not clearly documented that it does, but in my tests that did return the desired result.

Replies

I found the solution myself by trial-and-error:

The NSURL resource key NSURLVolumeNameKey contains the original name. It's not clearly documented that it does, but in my tests that did return the desired result.