Copy link to clipboard
Copied
I have thought of two approaches to this because my folder with 2000 PDF files contains many files that only have one page.
1) Somehow find a way to determine the PDF files with more than one page, then run a script to extract and save the first page of every PDF with > one page i.e., to another folder.
2) Run a javascript in Adobe Acrobat XI to extract the first page of all 2000 PDF files in my folder and save the resulting PDFs to another folder.
I wish if possible to do this without all 2000 PDF windows opening up during the process---which will no doubt crash my computer if I try to do this will all 2000 PDF files!
So far, I have tried using the Action Wizard which carries out 3 steps:
Execute JavaScript:
Delete pages:
Save
If I do it like this, all the files within my folder start to open. I ended the task before anything like 2000 PDFs were opened. Also, this delete option failed as it seems to be specific?
Does anybody know of a way to achieve the extraction of the first page of multiple PDF files followed by the saving of the extracted PDF files to another folder?
Kind regards,
Doug.
You are on the right track, but processing 2000 files in one action may be a bit too much for Acrobat. In general, Acrobat's automation tools are not designed for continuous operation, and in my experience, you will have to limit how many files you process in one batch.
Here is how I would do this: Let's assume you have a folder called "TheFiles", and one on the same level called "FirstPages", you can use a script that extracts the first page of a document that has more than one page and write th
...Copy link to clipboard
Copied
You are on the right track, but processing 2000 files in one action may be a bit too much for Acrobat. In general, Acrobat's automation tools are not designed for continuous operation, and in my experience, you will have to limit how many files you process in one batch.
Here is how I would do this: Let's assume you have a folder called "TheFiles", and one on the same level called "FirstPages", you can use a script that extracts the first page of a document that has more than one page and write that first page with a new filename to the "FirstPages" output folder.
To find out if the document has more than one page, you can use the Doc.numPages property. To extract the first page, I would use the Doc.extractPages() command, but with the output filename specified (see here fore more information: Acrobat DC SDK Documentation )
if (this.numPages > 1) {
// determine the current filename
var idx = this.path.lastIndexOf('/');
var baseFileName = this.path.substring(idx+1).replace(/\.[pP][dD][fF]/, "");
var fileName =
this.extractPages(0, 0, "../FirstPages/ " + baseFileName + "_1.pdf");
}
You can of course modify e.g. the output folder or the output filename.
The reason why Acrobat kept opening more and more files is that you did not use the version of the exportPages function that just silently writes out the exported pages and does not actually open the resulting document in the viewer.