Skip to main content
AJA-19070558
Known Participant
April 13, 2018
Answered

Batchprocessing with Acrobat DC

  • April 13, 2018
  • 1 reply
  • 836 views

Hi,

I would like to extract the first page each out of a batch of pdf files and store it in one separat folder on a Apple MAC.

I've got the information, that there ist no action in Acrobat itself.

May be someone knows something about an combination with Acrobat and the Automator program from Apple?

Or, is there a Script for those doings?

Thanks for help.

Alfred J.

This topic has been closed for replies.
Correct answer try67

Don't know where you found this information, but it can certainly be done using a script and an Action in Acrobat Pro (which I assume you have, since you're on a Mac).

The folder must exist in advance, though. The script can't create it for you.

The tricky part is to find the internal path of that folder.

To do so put a PDF file there and then open it in Acrobat.

Then press Cmd+J to open the JS Console, and paste this code into it:

this.path

Then press Cmd+Enter (using the Enter key in the numeric pad) and it will print out the file path.

Copy everything up to the file name, including the forward slashes, and then you could use that in the code to extract the first pages of your files, which will be:

var outputPath = "..."; // replace ... with the text you copied before

this.extractPages(0, 0, outputPath + "Page 1 from " + this.documentFileName);

That's it. You can run this Action on your files and the first page from each one will be saved in that folder.

If you need help setting up the Action let me know.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 13, 2018

Don't know where you found this information, but it can certainly be done using a script and an Action in Acrobat Pro (which I assume you have, since you're on a Mac).

The folder must exist in advance, though. The script can't create it for you.

The tricky part is to find the internal path of that folder.

To do so put a PDF file there and then open it in Acrobat.

Then press Cmd+J to open the JS Console, and paste this code into it:

this.path

Then press Cmd+Enter (using the Enter key in the numeric pad) and it will print out the file path.

Copy everything up to the file name, including the forward slashes, and then you could use that in the code to extract the first pages of your files, which will be:

var outputPath = "..."; // replace ... with the text you copied before

this.extractPages(0, 0, outputPath + "Page 1 from " + this.documentFileName);

That's it. You can run this Action on your files and the first page from each one will be saved in that folder.

If you need help setting up the Action let me know.

AJA-19070558
Known Participant
April 13, 2018

Hi try67,

many thanks for this.

First I,ve never programmed any skript intentional.

I did an batch with the Apple Automator for multi renaming, not more.

In which App or program I have to copy the code for this action?

Is it internal Acrobat or is it an extra Skript Editor?

Where do I advice the skript which pdf files it should use? The aim folder from above, is where the single pages will be stored.

I tried it with the onbord Skript Editor and got an error with "this.extractPages" as no function.

So my questions are

Which app contains the code?

How do I have to collect the source files for the action?

How to start the action?

As the path is for one folder, the next time I will need to change the skript, or get them all in the named one.

Alfred J.

try67
Community Expert
Community Expert
April 13, 2018

> Which app contains the code?

- Adobe Acrobat Pro

> How do I have to collect the source files for the action?

- You go to Tools - Action Wizard and create a new Action.

Add to it a "Run a JavaScript" command and paste the code into the editor window that opens.

Then you save the Action. Let's call it "Extract First Pages".

When you run this Action you will be able to select which files it processes. See the next question.

> How to start the action?

- Go again to Tools - Action Wizard and click on "Extract First Pages" you just created.

Click the Add Files/Add Folder button to select which files to run it on, and then click on Start.

Wait until it processes all the files and then check out output folder.

It's possible the last file will remain open (it's a bug in Acrobat). You can close it manually.

> As the path is for one folder, the next time I will need to change the skript, or get them all in the named one.

- Sorry, I don't follow what you mean. If you want to change the path of the folder where the extracted pages are located you will need to edit the code before running the Action.