Try this script:
var options = {
params: []
};
for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
var Filename = pdfe.SelectedFiles(i).Filename;
var fileOpt = {
type: 'edit',
name: i,
label: 'Copies of ' + Filename,
def: 1
};
options.params.push(fileOpt);
}
try {
options = JSON.parse(pdfe.DialogBox(JSON.stringify(options)));
if (options.Canceled) {
pdfe.echo('canceled');
pdfe.quit();
}
} catch (err) {
pdfe.quit();
}
var Merger = pdfe.CreateDocumentMerger();
var ProgressBar = pdfe.ProgressBar;
ProgressBar.max = pdfe.SelectedFiles.Count;
for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
var File = pdfe.SelectedFiles(i);
var Filename = File.Filename;
pdfe.echo(Filename);
ProgressBar.position = i + 1;
var copies = parseInt(options[i]) || 1;
for (var n = 0; n < copies; n++)
Merger.MergeDocument(Filename);
}
var dialog = pdfe.SaveDialog;
dialog.DefaultExt = '.pdf';
dialog.filter = 'PDF documents (*.pdf)|*.pdf';
dialog.Options = '[ofOverwritePrompt]';
dialog.Filename = Filename.substring(0, Filename.lastIndexOf('.')) + '_merged.pdf';
if (dialog.execute) {
Merger.EndAndSaveTo(dialog.Filename);
pdfe.echo('Done.');
}