Answered
Manan JoshiCorrect answer
Community Expert
Oct 10, 2026 9:54 AM UTC
Try the following code
function findImage(container) {
while(container.pageItems.length)
container = container.pageItems[0]
if(container)
return container
else
return ""
}
var container, img
for(var i = 0; i < app.documents[0].stories.length; i++) {
var rectCol = app.documents[0].stories[i].rectangles
for(var j = 0; j < rectCol.length; j++) {
container = rectCol[j]
img = findImage(container)
if(img != ""){
app.select(img)
app.cut()
app.select(container)
app.pasteInto()
}
}
}There are many assumptions made but you get the idea. Let me know if this is what you are after or not
-Manan

