Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Engaged ,
Sep 27, 2023 Sep 27, 2023

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");
}

 

TOPICS
Scripting
562
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 01, 2023 Oct 01, 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 < 
...
Translate
LEGEND ,
Sep 27, 2023 Sep 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 01, 2023 Oct 01, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 01, 2023 Oct 01, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 02, 2023 Oct 02, 2023
LATEST

Thank you so much @gregreser now the script works as expect, you saved my many clicks.

 

"|clip" was the unwanted code in this case, I was not realized it at starting, but now I removed it from the existing code before use this script. and its working perfectly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines