Skip to main content
j.khakase
Inspiring
September 27, 2023
Answered

help me to customize code to copy all path of selected items.

  • September 27, 2023
  • 1 reply
  • 883 views

Hello Friends,

I found below code to copy path of the selected object in Adobe bridge. but the issue is even I select multiple images its copy only one path. can somebody help me to customize this to copy all path of selected items.

 

#target bridge   
   if( BridgeTalk.appName == "bridge" ) {  
bridgePath = new MenuElement("command", "Path to Clipboard", "at the end of Thumbnail");
}
bridgePath.onSelect = function () { 
   pathToClipboard();
   }
function pathToClipboard(){
var sels = app.document.selections;
app.system("echo "+decodeURI(sels[0].spec.fsName) +"|clip");
}

 

This topic has been closed for replies.
Correct answer gregreser

app.document.selections returns an array of thumbnail objects, so you would loop through each array item to read the path(s). 

 

You could create an array to hold these paths and then push them to the clipboard.

 

In this example, the paths are joined by a line break ("\n"), but they could be comma or tab separated, depending on what you want to do with them. 

function pathToClipboard(){
var pathsArray = []; // array to hold selection paths
var sels = app.document.selections;
for(var i = 0; i < sels.length; i++){ // loop through each selecttion
    pathsArray.push(decodeURI(sels[i].spec.fsName) +"|clip"); // add the path of each selection to pathsArray
    app.document.copyTextToClipboard(pathsArray.join("\n")); // put each item in pathsArray on a new line in the clipboard
    }
}

 

What does "|clip" do?

1 reply

Brainiac
September 27, 2023

https://www.w3schools.com/js/js_loop_for.asp

Really, you are a *long* way from writing functional code if you don't know about loops.

j.khakase
j.khakaseAuthor
Inspiring
October 2, 2023

I am not developer, How to use this loop in shared code, I can only run the script

gregreser
gregreserCorrect answer
Brainiac
October 2, 2023

app.document.selections returns an array of thumbnail objects, so you would loop through each array item to read the path(s). 

 

You could create an array to hold these paths and then push them to the clipboard.

 

In this example, the paths are joined by a line break ("\n"), but they could be comma or tab separated, depending on what you want to do with them. 

function pathToClipboard(){
var pathsArray = []; // array to hold selection paths
var sels = app.document.selections;
for(var i = 0; i < sels.length; i++){ // loop through each selecttion
    pathsArray.push(decodeURI(sels[i].spec.fsName) +"|clip"); // add the path of each selection to pathsArray
    app.document.copyTextToClipboard(pathsArray.join("\n")); // put each item in pathsArray on a new line in the clipboard
    }
}

 

What does "|clip" do?