Skip to main content
Tomsing
Participant
April 24, 2023
Answered

Find unwanted duplicate photos

  • April 24, 2023
  • 4 replies
  • 1645 views

Hi all,

I produce books with indesign that often have hundreds of pages and even more images.
It happens that I accidentally use the same image twice.
I am looking for a way to search my links to see if there are unwanted duplicates.
Any ideas, scripts which might help?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Eugene Tyson

This is a bit crude - just trying to see if it works for you

It will create a text file on your desktop listing the images that are duplicated and what pages they are on

 

var allLinks = app.activeDocument.links;

var imageLinks = {};

for (var i = 0; i < allLinks.length; i++) {
  var linkName = allLinks[i].name;
  var parentObj = allLinks[i].parent;
  var pageNum = parentObj.parentPage.name;
  if (!imageLinks[linkName]) {
    imageLinks[linkName] = [pageNum];
  } else {
    imageLinks[linkName].push(pageNum);
  }
}


var file = new File("~/Desktop/image_links.txt");


file.open("w");

for (var linkName in imageLinks) {
  if (imageLinks[linkName].length > 1) {
    file.writeln(linkName + ': Pages ' + imageLinks[linkName].join(', '));
  } else {
    file.writeln(linkName);
  }
}

file.close();

alert('Image links have been saved to the file "image_links.txt" on your desktop.');

4 replies

Eugene TysonCommunity ExpertCorrect answer
Community Expert
April 24, 2023

This is a bit crude - just trying to see if it works for you

It will create a text file on your desktop listing the images that are duplicated and what pages they are on

 

var allLinks = app.activeDocument.links;

var imageLinks = {};

for (var i = 0; i < allLinks.length; i++) {
  var linkName = allLinks[i].name;
  var parentObj = allLinks[i].parent;
  var pageNum = parentObj.parentPage.name;
  if (!imageLinks[linkName]) {
    imageLinks[linkName] = [pageNum];
  } else {
    imageLinks[linkName].push(pageNum);
  }
}


var file = new File("~/Desktop/image_links.txt");


file.open("w");

for (var linkName in imageLinks) {
  if (imageLinks[linkName].length > 1) {
    file.writeln(linkName + ': Pages ' + imageLinks[linkName].join(', '));
  } else {
    file.writeln(linkName);
  }
}

file.close();

alert('Image links have been saved to the file "image_links.txt" on your desktop.');
Tomsing
TomsingAuthor
Participant
April 25, 2023

Thanks much!

 

Willi Adelberger
Community Expert
Community Expert
April 24, 2023

Look into the link panel, any image that is used multiple times is grouped and shown that is used multiple times.

Tomsing
TomsingAuthor
Participant
April 25, 2023

Thanks much!