How to get the path name from selected finder item?

I'd like to create a custom context menu, which takes the path name of the selected item and after transforming it copies it to the clipboard. However it is unclear, which action accomplishes that. So far I've only find "transform clipboard with Javascript" which probably does the trick when I'm able to get the selection and its path name...

I think this will help you:

Depending on what you would like to do, this something you can achieve well with the Shortcuts app (which you can then call from BTT):

If you want to do it fully in BTT instead, you can use some Java Script for Automation / Apple Script with BTT's "Run Real Java Script" action. Here is an example:

Hint: use chatgpt to further adapt this example to your needs

async function transformPaths() {
  // this is some apple script in JAX (Java Script For Automation) format, which gets the current finder paths
  let script = `var finder = Application('Finder');
             var selection = finder.selection();

             var paths = selection.map(file => file.url().slice(7)); // Remove "file://"
             var jsonArray = JSON.stringify(paths);
             jsonArray
            `;

   //get the selected file paths by running the above script, then parse them into an array:
  let selectedFilesString = await runJAX(script);
  let selectedFilesArray = JSON.parse(selectedFilesString);

 // apply some transformation and join the file paths with a new line:
  let transformed = selectedFilesArray.map(path => path + "lala").join("\n");
	
	
	// copy the transformed paths to the clipboard:
   let result = await set_clipboard_content({content:transformed, format: 'NSPasteboardTypeString'})


  return transformed;


}


Just FYI, it is useful in some cases the default shortcut in macos.

In Finder, "alt+cmd+c" copies the path of the selected item to the clipboard.

Sorry for the late answer and thanks for the suggestions! It works now via the Shortcuts solution. It's a bit unclear on how to integrate that into the Finder context menu item, as "get Finder selection" is not the right way to get items chosen for the context menu. Do I have to pass a specific BTT variable into the shortcut?

Also thanks for the keyboard shortcut to copy paths - I didn't know that :-).

what kind of context menu do you want? are you using the “show context menu (new)” action or the finder context menu additions that display directly in the Finder context menu?

Thanks again for the reply and sorry für being unprecise - I didn't know that there are several ways to do context menus :-). So far I have configured:

and within that:

Which triggers the shortcut: