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.