Skip to main content
Participant
January 8, 2017
Answered

How do I Remove the Last Page from Multiple Files without knowing the page number?

  • January 8, 2017
  • 4 replies
  • 12983 views

I am trying to figure out a way to batch process to remove the last page of documents automatically and have DC identify it without me having to add the individual page numbers toi delete.

This topic has been closed for replies.
Correct answer try67

You can do it using this code:

this.deletePages(this.numPages-1);

4 replies

Participant
December 11, 2021

Thank you so much. HAPPY HOLIDAYS.!

JR Boulay
Community Expert
Community Expert
December 11, 2021

if (this.numPages > 3) this.deletePages({nStart: this.numPages-2, nEnd: this.numPages-1});

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 8, 2017

You can do it using this code:

this.deletePages(this.numPages-1);

Participant
January 9, 2017

Where do I put this and how do I apply it. I have never seen anything like this and I'm in the New Custom Command and ????

try67
Community Expert
Community Expert
January 9, 2017

No, you need to go to Tools - Action Wizard and then create a new Action.

Add to it an "Execute JavaScript" command (from the More Tools section) and a Save command (from the Save and Export section).

Open the first command and then click on Specify Settings. Paste the code I provided above into the window that opens and click OK.

Make sure to un-tick the "Prompt User" check-box underneath it.

Now save your Action and you can run it from the Action Wizard by clicking it. Select which files/folders to process and click on Start.

Be aware that this process is NOT reversible, so make sure you have a backup of your files before running it, just in case of any problems.

PS. Use this code, actually, or you'll get an error message for files with just one page:

if (this.numPages>1) this.deletePages(this.numPages-1);

kglad
Community Expert
Community Expert
January 8, 2017