Skip to main content
Inspiring
October 17, 2022
Question

list open and update group of link and note single link

  • October 17, 2022
  • 1 reply
  • 1088 views

hi with this function

 

function OpenAndUpdate(doc){
	app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
    //$.writeln("ouverture d'un sous lien : " +  doc);
	internal_link = doc.links;
	var nb_link = 0;
	try {
  		nb_link = internal_link.length;
	} catch (error) {}
    //$.writeln(internal_link);
    //$.writeln("nombre de liens dans ce fichier : " + internal_link.length + "nombre de link : " + nb_link ) //+ internal_link[k]);
	if (nb_link > 0) {
			doc.links.everyItem().update();
			doc.save();
	    for(var k = 0; k < nb_link; k++){
			internal_link = doc.links;
			if (k > 0){
			internal_link[k].update();
			}
		    // On vérifie que le lien est OK :
		    if (internal_link[k].status == LinkStatus.LINK_MISSING){
			    var folderPath = (Folder.selectDialog(internal_link[k].filePath));
			    var imglist = Folder(folderPath).getFiles(internal_link[k].name+".*");
			    if (imglist.length == 1){
				internal_link[k].relink(imglist[0]);
			    }

		    }
		    // Si le lien est ok. On l'ouvre pour vérifier ses propres lien. La recursivité a lieu ici:
		    //$.writeln("Lien numéro " + k + " : type de fichier " + internal_link[k].linkType + " alors que seul les indd sont mis à jour");
		    if (internal_link[k].linkType == 'InDesign Format Name') { // Je ne veux ouvrir que les fichier indd
                //$.writeln("ouverture d'un sous lien. entrée dans une boucle récursive");
				newdoc = app.open(internal_link[k].filePath);
			    OpenAndUpdate(newdoc) // pas sur. peut etre Filepath à la place de File. cf la doc: https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Link.html
			}
		}
	}
	if(doc.links.length > 0)
	{
		app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
		doc.links.everyItem().update();
		doc.close (SaveOptions.YES);
	}
	else{
		doc.close();
	}
    return 0; // fin de la fonction. Elle ne renvoie rien normalement
	alert("merci")
};

 

we open with recursion all link inside a file

 

but i have so much link into my source file, arround 130 link divide into only 9 different files

 

if i open and update the group of link and not the only the single link, i will save my time per 10

 

i attached 2 picture for show you

 

i need to update 70 principal indd file, each file contain 130link divide in 9 files, each file contain again lot of link....

 

 

thanks for your help

 

i give an idea, but if it s too complicate to find the "group of link file"

mauybe we can write the path file into a csv, and before open a new link, we read the csv, if path file exist we not open, if not exist we can open?

 

i give idea but i m not able to write script for that

This topic has been closed for replies.

1 reply

Loic.Aigon
Legend
October 17, 2022

There is no such thing as a links group in the InDesign DOM. I think that from the UI perspective, it's just a commodity. So basically, you have to update all Link instances.

Inspiring
October 17, 2022

i feel update all link will take several day, it s not really possible

 

maybe my second solution is possible?

for each open link will read a pathfile memory, if it is empty, we note the pathfile in it. if the pathfile already exists, can't we open the file a second time? What do you think?

Loic.Aigon
Legend
October 17, 2022

Not sure I am following you but you may be talking about some kind of tracking the link file you have processed? Feel free to bring more details. But once again, as many link instances, you have, as many of them you have to process. You can try relinking (relink()) over update and see if there are any performance improvements.

 

Something worth analyzing is your link usage. Hard to tell from screenshots but is the file really optimized? That would be a serious way to reduce the number of link instances. I have worked with Packaging related InDesign files and links have never been an issue.