Inspiring
October 17, 2022
Question
list open and update group of link and note single link
- October 17, 2022
- 1 reply
- 1091 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
