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

copy filepath to clipboard [SOLVED]

New Here ,
Sep 21, 2019 Sep 21, 2019

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.

TOPICS
Scripting
1.5K
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 , Sep 22, 2019 Sep 22, 2019

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

...
Translate
Enthusiast ,
Sep 22, 2019 Sep 22, 2019

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?

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 ,
Sep 22, 2019 Sep 22, 2019

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 )

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
New Here ,
Sep 22, 2019 Sep 22, 2019

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!

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
Enthusiast ,
Sep 23, 2019 Sep 23, 2019
You change File( graphicsInSelection[n].itemLink.filePath ).fullName to File( graphicsInSelection[n].itemLink.filePath ).fsName
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
New Here ,
Sep 24, 2019 Sep 24, 2019
LATEST
Spectacular! THANK YOU
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