I have a indesign document with several images. I want to update these images with Adobe Indesign Scripting. The following code works.
var file = new File ('/MyDisk/image01.png'); app.activeDocument.links.item(1).relink (file); var file = new File ('/MyDisk/image02.png'); app.activeDocument.links.item(2).relink (file);
But you have to know the index of the link you want to change. If you're adding/deleting images on the page, this numbering can change. So I rather use the name of the pageItem itself. But I don't know how to do this.
With textItems, it is easy to refer to a object's name, but to change an image link by referring his name seems not possible. example:
app.activeDocument.textFrames.item('text frame').contents= 'changed content';