This website contains various projects I have worked on. Currently, this includes JavaScripts for Adobe applications and general produciton tutorials using Adobe Creative Suite applications. All projects can be accessed from the right-hand menu.

image of a notepad
Getting a list of all your links in an InDesign document

Script Description

Someone posted the question to the InDesign Secrets blog “How do I get a list of all the links within my InDesign Document?” I wrote a script that could do just that.

Looking at the script

The basic concept of the script is this: Open a dialog box to get some input from the user, add up the total number of links in the document, create a new text-frame to display the results, loop through all the links and write their properties into the new text box. That’s it!

In the first part of the script I create a dialog box. The dialog box uses radio buttons to find out what information about the links the user needs. The options are: link file names, the filepaths of the links, and the file types of the links.

// ----- Dialog Box ------\\
var myDialog = app.dialogs.add({name:"Link Lister", canCancel:true});
with(myDialog){
	with(dialogColumns.add()){
		with(borderPanels.add()){
			}
		with(borderPanels.add()){
			staticTexts.add({staticLabel:"What link information do you want? "});
			}
		with(dialogColumns.add()){
			with(borderPanels.add()){
					var myLeftRadioButton = checkboxControls.add({staticLabel:"Names", checkedState:true});
					var myCenterRadioButton = checkboxControls.add({staticLabel:"Paths"});
					var myRightRadioButton = checkboxControls.add({staticLabel:"File type"});
				}
			}
		}
	}
	
// ----- End of Dialog Box ----- \\

Now, if the the user didn’t cancel the dialog box, I start to set some variables. I find the open document and set totalLinks to the total number of links in the document. Next I create the text frame to show the results. The text frame is created in the upper left corner of the document, assuming the rulers are set to the default position.

if(myDialog.show() == true){

	var myDocument = app.activeDocument;
	var totalLinks = myDocument.links.length;

	var myNewTextFrame = myDocument.textFrames.add() // Add a text frame to display the list of links
	myNewTextFrame.geometricBounds = [ "0p0", "0p0", "50p5", "50p5"];

Finally, I loop through all the links and depending on the input from the dialog box, I show the link properties. There are other properties of links not included in this script, that could be easily added.

for ( i = 0;  i  < totalLinks;  i++ )
	{
		if (myLeftRadioButton.checkedState == true)
		{
			myNewTextFrame.contents = ( myNewTextFrame.contents + "File: " + myDocument.links.item(i).name );
		}
		if (myCenterRadioButton.checkedState == true)
		{
			myNewTextFrame.contents = ( myNewTextFrame.contents + " Path: " + myDocument.links.item(i).filePath );
		}
		if (myRightRadioButton.checkedState == true)
		{
			myNewTextFrame.contents = ( myNewTextFrame.contents + " Type: " + myDocument.links.item(i).linkType );
		}
		myNewTextFrame.contents = ( myNewTextFrame.contents + '\r' );		
		
	}
}
myDialog.destroy();

Installing the script

Installing this script, or any InDesign script is really easy. Just place the .js or .jsx file into the scripts folder within your InDesign application folder. Such as, C:\Program Files\Adobe\Adobe InDesign CS2\Presets\Scripts.


back to top

Image of a notepad

Script table-of-contents

Script files


Other Projects:

Adobe JavaScripts ↑↓

Adobe Creative Suite Tutorials ↑↓



Have you ever needed a list of links from InDesign?

Yes.
No.
I do now!