When using this option on a file on a network drive, I get a path with the file:// prefix.
I’d expect to get the server path, so I can share this URL with other users.
Now I am getting file:///Volumes/Bla/Foo/File.txt
I would expect to get smb://serverurl/Bla/Foo/File.txt, which is the path I see when I right-click and select Get Info on the file
One other user requested this functionality. The problem is how to determine
serverurl from a filesystem path. At the time I didn’t know how to do that, so I proposed following functionality. It is implemented in TotalFinder, so you might give it a try. Or please propose some similar scheme how TotalFinder should determine translation from filesystem paths to share-able urls.
// Adding a new option in that context menu is simple. The problem is how
// to determine UNC path server and volume name from Mac. I think we
// should define some convention for this.
// Here is my proposal:
// UNC path will be constructed as follows \\server\volume\path
// let $file be absolute selected file path e.g /Volumes/myshare/some/dir/file.txt
// option to copy UNC path will be available only if $file begins with /Volumes/
// "path" is $file without first two folders, => /some/dir/file.txt
// "volume" is second folder in $file => myshare
// "server" is empty by default =>
// Additionally I will walk down from $file visiting every parent folder.
// If I find file named .unc-hint I will stop and read it as a config
// file. Config file may override "volume" and "server":
// .unc-hint is a text file, with up to two lines, the first is server
// name, the second is volume name.
// This would enable you to put .unc-hint file anywhere on your shared
// samba volumes (ideally into volume's root) to define server name.
How about this code:
NSError *error=nil; //Error
NSURL *volumePath=nil; //result of UNC network mounting path
NSString* testPath =@"/Volumes/Bla/Foo/File.txt"; //File path to test
NSURL *testUrl = [NSURL fileURLWithPath:testPath]; //Create a NSURL from file path
[testUrl getResourceValue:&volumePath forKey:NSURLVolumeURLForRemountingKey error:&error]; //Get real UNC network mounted path i.e. smb://....
if(volumePath != nil)
return [NSString stringWithFormat:@"%@://%@%@", volumePath.scheme, volumePath.host, [testUrl.path substringFromIndex:[@"/Volumes" length]]];
This looks good. Thanks! I will implement it in the next TF version.
I have implemented this in TF 1.10.0:
In the end had to use slightly more complex code because network mount points don’t necessary have to be in
/Volumes only. But thanks for the idea.
Thanks for the implementation.
Do note that the path I receive from your code includes my username as a prefix (smb://username@server/bla)
My sample code has intentionally removed it since when sharing URLs, my username should not be included
Interesting. Yes, I blindly used what system reported as mount volume url. This might be just your case that user is not important with your smb shares (which are probably public) but might be important in some other cases (e.g. with afp shares). So I’m reluctant to massage the url in any way.
I’m going to implement stripping of the user name, hidden behind a plist tweak. So you can enable it for yourself.
TotalFinder 1.10.1 has added two plist tweaks.
In Terminal.app you can do:
defaults write com.binaryage.totalfinder TotalFinderStripUserFromPathURLs -bool yes
defaults write com.binaryage.totalfinder TotalFinderStripPasswordFromPathURLs -bool yes
To remove the tweak:
defaults delete com.binaryage.totalfinder TotalFinderStripUserFromPathURLs
defaults delete com.binaryage.totalfinder TotalFinderStripPasswordFromPathURLs
Finder+TotalFinder restart is needed.
Can confirm it is working now. Thank you very much!
Love the clickable links to server locations. Wondering if there is a way to make the clickable URL direct to the actual server location instead of a network mount point? Would make sharing even better to be able to give someone else access to the whole server path instead of just a mount point. Looking to get my entire office operating on Totalfinder and this functionality would go a long way. Not a coder. Sorry if this is an impossible request. Thanks for making this awesome app and for any info you can send my way.
I have been looking into AFP servers and it seems like the functionality I am referring to is the ability for the program to process the path name. I have tried a few other programs and they don’t have this functionality either. Path Snagger 2 comes the closest in that it can provide an afp link that processes the entire path name but only in Outlook not in Mail or Slack. The paths it produces start with the prefix ‘file:///volumes/’. Being able to share a fully processed server path in my office of 50 plus people would be a huge time saver.
I’m sorry I don’t deeply understand this AFP or network volume sharing. But I just did a quick test of the new TotalFinder functionality requested by Mark (original poster) and it seems to work like this on my machine with macOS 10.13.5.
I connected to another machine “minime” on LAN via Finder’s sidebar item and this mounted a volume via AFP. Then in TotalFinder I right-clicked folder “jarek” (mounted at
/Volumes/MAMUT1/jarek) and selected Copy Path -> URL from the context menu. The URL produced was
afp://darwin@minime._afpovertcp._tcp.local/MAMUT1/jarek/. This is correct URL from the TotalFinder’s perspective, because it really contains some DNS name, not a file path alone. But it does not resolve when I try to ping
I just googled and it looks like the problem is described here:
I can confirm the behaviour, I tried to connect to the same machine via
Go -> Connect to Server ... and entered local LAN DNS name for the minime machine
minime.lan and mounted MAMUT1 again. TotalFinder’s Copy Path -> URL then returned
afp://email@example.com/MAMUT1/jarek/. Which is expected and works.
I think to make this work in all cases you would have to configure your DNS server to resolve _afpovertcp._tcp.local to relevant IPs. In my case I would have to map [something]._afpovertcp._tcp.local -> [something].lan or hard-code a list of known machine IPs (which would be less flexible).
Just my $.02. Not sure if this is relevant to your problem at all.
Thanks this was very helpful.