Copy link to clipboard
Copied
Hi, i need copy path of selection (one or more links) to clipboard. I know i can use shortcut directly in InDesign, but it works only if links panel is open and i work without panels 🙂 So can JS help me? - windows 10
Thanky a lot.
Hi Lukas,
do you mean to copy the path of a placed and linked graphic to the clipboard?
And that with all paths you can find in a selection of objects?
You could work with the allGraphics array of every selected item, concatenate all found allGraphics arrays and loop the resulting array. In the loop you check two things:
1. Is there an item link? If not the graphic is pasted. Then loop on.
2. If there is an item link you could read out the file path.
Add every file path to the result array.
Add a new
...Copy link to clipboard
Copied
Sorry, I don’t understand what you mean by „path of selection“. Could you add a screenshot please? Do you copy the Element from one InDesign document to another or from a different software, and if so which one?
Copy link to clipboard
Copied
Hi Lukas,
do you mean to copy the path of a placed and linked graphic to the clipboard?
And that with all paths you can find in a selection of objects?
You could work with the allGraphics array of every selected item, concatenate all found allGraphics arrays and loop the resulting array. In the loop you check two things:
1. Is there an item link? If not the graphic is pasted. Then loop on.
2. If there is an item link you could read out the file path.
Add every file path to the result array.
Add a new text frame to the document, assign the results as contents to the story of the text frame, select texts[0] of the story, do app.copy(). Remove the added text frame. Restore your selection.
Something like this in ExtendScript code:
var sel = app.selection;
var graphicsInSelection = [];
var resultArray = [];
for( var n=0;n<sel.length;n++ )
{
if( sel[n].allGraphics.length == 0 ){ continue };
graphicsInSelection = graphicsInSelection.concat( sel[n].allGraphics );
};
for( var n=0; n<graphicsInSelection.length; n++ )
{
if( graphicsInSelection[n].itemLink == null ){ continue };
resultArray[ resultArray.length++ ] = File( graphicsInSelection[n].itemLink.filePath ).fullName;
};
// Do something with the results:
var doc = app.documents[0];
var tempTextFrame = doc.textFrames.add();
tempTextFrame.parentStory.contents = resultArray.join("\r");
tempTextFrame.parentStory.texts[0].select();
app.copy();
tempTextFrame.remove();
app.select( sel );
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Almost perfect 🙂 your script give me this type of path:
~/Downloads/kitten.jpg
/c/Intel/Logs/kitten.jpg
so now i have to use another script program (AHK) to edit clipboard, because i need the same "pathstyle" like i get when i use links panel:
C:\Users\lzalesky\Downloads\kitten.jpg
C:\Intel\Logs\kitten.jpg
i`m very newbie with JS 😕
Thanks a million!
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now