Copy path of Info-window

Hello,
I am new here and hope to get help. What I want to do:

when selected a file in a server-window I like to hit a key-combination that does:

  1. open the Info-Window of the file
  2. copy the server-path of the file in the clipboard
  3. go to (let's say) the app TextEdit
  4. insert the path as text

Is there a way to automate this with BTT?

What do you mean by "server window" ? What application are you using ?

I mean a Finder window of a connected server, especially my NAS.

Oh, OK. So essentially, you have a Finder window open, and there’s a file you’ve selected for which you’d like to obtain its path and have it inserted into a TextEdit document ?

I’ll assume you know how to attach a script to a hotkey in BTT to have it execute whenever you press the key combo. So the script part of it would probably be this:

property text item delimiters : linefeed


tell application id "com.apple.Finder" to set ¬
		filepaths to selection as alias list

if {} = filepaths then return beep

repeat with fp in filepaths
		tell fp to set the contents of ¬
				it to its POSIX path
end repeat

tell application id "com.apple.TextEdit" to if ((make new ¬
		document with properties {text:filepaths as text}) ¬
		exists) then activate

###if you also need the filepaths copied to the clipboard
###then you can uncomment the line below
# set the clipboard to the filepaths as text

Thanx. That almost what I need. If I take your Apple-Script I get a path like

/Volumes/Harddisk1/XXX.pdf

But the server path on the NAS should be like. This is the path I see in the info-window of the file.

smb://nasname._smb._tcp.local/Harddisk/XXX.pdf

Here i found a hint for the solution:

hint

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

<