Hi Barb, I am so sorry for the delay and for posting a broken script! I tried the script and found some errors being written to the Console. Here is the updated, working version. Note that the script will delete the anchored frame containing the image. If you want to keep the anchored frame and just delete the image, replace this line:
aframes.push (parent);
with this:
aframes.push (graphic);
Here is the updated script:
main ();
function main () {
var doc;
doc = app.ActiveDoc;
if (doc.ObjectValid () === 1) {
processDoc (doc);
}
}
function processDoc (doc) {
var regex, aframes, count, i;
regex = /rocketwide\.ai$/i;
// Turn off the displaying property to speed the script and prevent flicker.
if (app.Displaying === 1) {
app.Displaying = 0;
}
// Get the anchored frames that contain an image matching
// a regular expression pattern.
aframes = getAFrames (doc, regex);
// Delete the anchored frames.
count = aframes.length;
for (i = 0; i < count; i += 1) {
aframes[i].Delete ();
}
// Restore the document display and refresh the screen.
if (app.Displaying === 0) {
app.Displaying = 1;
doc.Redisplay ();
}
}
function getAFrames (doc, regex) {
var aframes, graphic, parent;
// Make an array to store the anchored frames.
aframes = [];
// Loop through the graphics in the document.
graphic = doc.FirstGraphicInDoc;
while (graphic.ObjectValid () === 1) {
// Test for an imported graphic.
if (graphic.constructor.name === "Inset") {
// See if the imported graphic matches the regular expression.
if (regex.test (graphic.InsetFile) === true) {
// Get the parent frame of the graphic.
parent = graphic.FrameParent;
// Make sure it is an anchored frame.
if (parent.constructor.name === "AFrame") {
// Push it onto the array.
aframes.push (parent);
}
}
}
graphic = graphic.NextGraphicInDoc;
}
// Return the array of anchored frame objects.
return aframes;
}