I'm trying to come up with a simple script that relinks an image (eps file) in Indesign.
This is what I've come up with so far
//find item and get path
var myItem = app.activeDocument.links.item("MyCurrentimage.eps");
var myItemPath = myItem.filePath;
//define new image path
var newPath = "P:\\images\\otherfolder\\newimage.eps";
//relink
myItem.relink(myItemPath,newPath);
I keep getting a message saying "Cannot create the link resource from the given URI". Any ideas? Thanks!
I finally got it to work by using relink
with new File()
//target item
var itemIwantToReplace = app.activeDocument.links.item("MyCurrentimage.eps");
//relink
itemIwantToReplace.relink(new File("P:\\Images\\myNewImage.eps"));
这实际上只是一个猜测,但也许它会将您的newPath
视为一个字符串,而不是一个 URI,因此您需要传递一个实际的 URL 对象。
var newPath = new URL("P:\images\otherfolder\newimage.eps");
You can use this:
var myItem = app.activeDocument.links.item("MyCurrentimage.eps");
var myItemPath = myItem.filePath;
var newPath = new File("P:\\images\\otherfolder\\newimage.eps");
myItem.relink(newPath);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.