AppleScript POSIX path to smb path I want to create an automator service that copies the full smb:// path of a folder or file (like you would get from ⌃ + ⌥ + ⌘ + C)
The reason the shortcut isn't enough is for all those &quot;older people&quot; (no offense intended) that can't remember shortcuts or don't want to use them at all (the typical rightclick -&gt; copy instead of ⌘ + C users).
So far I got the POSIX path but how do I transform it to my correct smb:// path?
on run
    tell application &quot;Finder&quot;
         set theItem to selection as string
    end tell
    set posixForm to POSIX path of theItem
    set the clipboard to posixForm
end run

So this path /Volumes/someFolder/someSubFolder/ would become this smb://Server/someFolder/someSubFolder/
You may need to URL Encode some characters and spaces, however, here is some example AppleScript code  that you may find helpful, although it only encodes spaces:
tell application &quot;Finder&quot; to ¬
    set theItem to the first item of ¬
        the (selection as alias list)

set posixForm to POSIX path of theItem

set {TID, AppleScript's text item delimiters} to ¬
    {AppleScript's text item delimiters, &quot; &quot;}
set foo to text items of posixForm
set AppleScript's text item delimiters to &quot;%20&quot;
set foo to foo as string
set AppleScript's text item delimiters to &quot;/&quot;
set foo to text items 3 thru -1 of foo
set foo to foo as string
set smbForm to &quot;smb://server/&quot; &amp; foo as string
set AppleScript's text item delimiters to TID

set the clipboard to smbForm


Notes:
Have a look at Encoding and Decoding Text in the Mac Automation Scripting Guide.


Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.