I have a script using the dynamic content plugin from illustrator which takes and XML file and replaces it with a new one. All linked text/symbol/image links have their paths updated or text content updated.
The problem I have is I have background images which are not dynamic so I need to relink these based on their file path.
We have two shares, an OPI & an FPO, because of the size of backgrounf images we keep the FPO links in whilst artworking.
What I'd like to do is relink all images if they contain FPO in their file path, I'm in CS5.1. I had a look and found CS6 has a .relink method but obviosuly this is no use to me in CS5.1
Any ideas or starting points?
I was looking at another script you have made:
// script.name = relinkAllSelected.jsx;
// script.description = relinks all selected placed images at once;
// script.required = select at least one linked image before running;
// script.parent = CarlosCanto // 7/12/11;
// script.elegant = false;
var idoc = app.activeDocument;
sel = idoc.selection;
var file = File.openDialog ("open file");
for (i=0 ; i<sel.length ; i++ )
if (sel[i].typename == "PlacedItem")
var iplaced = sel[i];
iplaced.file = file;
alert("select at least one placed item before running");
And it got me thinking.
If the variable
sel was actually an array of all placedItems in the active document, and I added a .replace() method to the "iplaced.file = file" line. Then would this relink the image in the array?
Lets say the placed items path was \SERVER\SHARE FPO\DFolder\Image_1.psd and I sinply did a .replace(/ FPO/,"") so my path now read \SERVER\SHARE\DFolder\Image_1.psd
you got the idea, but no, it is not that easy, replace() is a method of the String Object, while the file property expects a File Object. In short File Object does not support the replace() method.
you'll have loop thru your selection, get the path of the placedItem, apply your replace() method to this path to make a new path, make a new File Object out of this new string, apply to the file property.
Still getting my head around the file/class/object/method/property terminology and their appropriate uses.
I'll try and get some quiet time and give it a go this week. I'll return with my results.