3

I work in a Windows environment with many different shared drives. I commonly have Finder windows open to different shared drives and nested folders. I have a Service set up (that I created in Automator) that allows me to control-click and "copy full path" of a file or folder that I have selected in the Finder.

What I'm getting looks something like:

/Volumes/someFolder/someFile.docx

However, if I select that item in the Finder and do command-i, I see the full smb:// path that also includes the server name. I would like to copy this, so that it looks like:

smb://Server/someParentFolder/someFolder/someFile.docx

How can I create a service in Automator that will copy the entire smb:// network path to the selected file instead of the one that reports as being the full path?

If Automator won't copy the smb:// network path, is there another way I can create a utility that will do this?

5
  • 1
    possible duplicate of Is there a way to make Windows-style SMB share paths launch correctly? Commented Jun 10, 2014 at 4:58
  • @anthonyg That's not a duplicate. I'm not trying to create Windows-style SMB share paths that launch correctly. I want the OS X style SMB share path. I did find the other post useful for another issue, however.
    – Clay
    Commented Jun 10, 2014 at 13:21
  • There is an option in WinShortcutter to copy the path either Windows-style or OS X style (forward or backwards slashes) -- not sure if that will do what you want. Commented Jun 12, 2014 at 7:09
  • I saw that, thanks. That's not what I'm looking for because it doesn't include the full path with the server name, like the smb:// link does.
    – Clay
    Commented Jun 12, 2014 at 13:24
  • Aha. TotalFinder (totalfinder.binaryage.com) gives quite a selection of ways to copy paths (Windows, Posix, UNC, HFS, Terminal, URL), but nothing i can see with the server name. Commented Jun 12, 2014 at 13:34

3 Answers 3

2

You can right click the file, and choose "Get Info" - the popup window will have a property for Server which lists the full URL path with protocol (e.g. smb://example.com/Data/file.png)

1
  • does not work for me: there is no property for Server.
    – Beginner
    Commented Dec 22, 2018 at 17:12
1

Two years down the road this remains an annoying issue, and not finding a good answer to a similar question, I made an automator service that does this as part of the work needed to make an .inetloc file from the Finder.

Basically, it finds the mount point of the current share using the output of the mount command and matches it up to the 'mounted' path, then glues the two together like Iacopo mentioned above.

Here's how you could do what you want:

Pass the selected finder item to a shell script in automator (as a variable, not stdin) and use this script:

# Match the server address and share/subfolder to the mount point,
# using 'mount' command output:
FIRSTPART=$(mount | grep "$(echo $1 | cut -d '/' -f 1-3)" | sed 's/^.*@\(.*\) on.*$/\1/g')

# Glue on the rest of the path
SECONDPART=$(echo $1 | cut -d '/' -f 4-)
WHOLETHING=$FIRSTPART/$SECONDPART

# now we url encode it
# oneliner modified from http://stackoverflow.com/a/10797966
ENCODED=$(echo "$WHOLETHING" | curl -Gso /dev/null -w %{url_effective} --data-urlencode @- "" | cut -c 3- | rev | cut -c 4- | rev)
# and we need to change the %2Fs back into /s, and add the smb://

FINAL=smb://$(echo $ENCODED | sed 's/\%2F/\//g')

echo "$FINAL"

Then you can use a "Copy to Clipboard" action after the script. Should do the trick. If anyone wants the automator service to make the corresponding .inetloc file, that can be found here.

1
  • I modified this for use in our office. Thanks for posting! Commented Jun 22, 2017 at 19:22
0

I think you could easily fix that whit a bit of applescript and "sed".

I don't know how your original applescript looks like, but I assume you have a variable that contains the path /Volumes/someFolder/someFile.docx as you said, let's call that variable thePath. All you have to do is take thePath, remove /Volumes/ and add smb://Server/someParentFolder/

This code does that:

#the following line only removes /Volumes/someFolder, it could also add smb://ecc but it would look like a big mess, I think it's easier to add that prefix in a separate line of code
set relativePath to do shell script "echo \"" & thePath & "\" | sed 's/.*Volumes\/someFolder//'"

#now you add the smb prefix or whatever you want
set relativePath to "smb://Server/someParentFolder" & relativePath

then you are all set, use relativePath for your output instead of thePath and it should work, at least it worked for me :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .