Hello! I encountered this problem myself and came up with a solution that worked for me.
This is how I broke it down:
1: Create a dialog with an edit box where you type the number of pages in the document you wish to import.
2: Prompt the user to select a file to place.
3: Create a for loop that iterates through as many times as there are pages in the placed PDF
4: Import the page number of the PDF on the matching page number on the indesign file by refering to the current value of the counter for both.
Here are some segments of code from my script that may be of use to you:
1: with(borderPanels.add()){
staticTexts.add({staticLabel: "Page Count:"});
var PageCount = integerEditboxes.add({minimumValue: 1, maximumValue: 9999, editValue: 1, minWidth: 50});
}
var SelectedPageCount = parseInt(PageCount.editValue);
2: var Art = File.openDialog
3/4: function PlaceFile (Document, Art, SelectedPageCount) {
//Create a counter from the page count
var Counter = SelectedPageCount
// Automated Placement
for (Counter; Counter > 0; Counter --) {
app.pdfPlacePreferences.pageNumber = Counter;
var placeFile1 = Document.pages.item(Counter + "").place(Art, ["0.5in" ,"0.5in"])[0];
//This resets the imported page default to 1 for next time a document is placed
app.pdfPlacePreferences.pageNumber = 1;
}
}
I hope this is of use to you!