Find items via script label
I am a catalog production artist. I have been working with a JSX script which fetches and places INDD snippets from a folder based the file name. I would like to streamline my process by forgoing the Snippets, and simply copy the required text frames from one INDD document to another, identifying the required text frames by searching on the Script Label. I have this bit of code that works to select a specific text frame. However, once it finds the target, it doesn't do anything with it;
do
{
if (app.documents.length == 0)
{
break;
}
var document = app.activeDocument;
if (! (document instanceof Document))
{
break;
}
var currentItem = null;
if (app.selection.length > 0)
{
currentItem = app.selection[0];
}
var undoneItems = [];
for (var idx = 0; idx < document.allPageItems.length; idx++)
{
var pageItem = document.allPageItems[idx];
if (pageItem.label == "11010001")
{
undoneItems.push(pageItem);
}
}
if (undoneItems.length <= 0)
{
break;
}
var nextItemIdx = 0;
if (currentItem != null)
{
var currentItemIdx = -1;
var searchItemIdx = 0;
while (currentItemIdx == -1 && searchItemIdx < undoneItems.length)
{
if (undoneItems[searchItemIdx] == currentItem)
{
currentItemIdx = searchItemIdx;
}
searchItemIdx++;
}
if (currentItemIdx >= 0)
{
nextItemIdx = currentItemIdx + 1;
if (nextItemIdx >= undoneItems.length)
{
nextItemIdx = 0;
}
}
}
app.select(undoneItems[nextItemIdx]);
}
while (false);
However, the Script Label is hard coded in the script which you can see in the highlighted line above. What I want is to be able to do is feed a text document of 8 digit numbers, have the script walk though the entire INDD source file, and copy the found items from the text file into an empty INDD target file. An extra bonus would be if the script could return a report of items it did not locate when completed.
