• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Jan 08, 2017 Jan 08, 2017

Copy link to clipboard

Copied

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.

TOPICS
Edit and convert PDFs

Views

8.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 08, 2017 Jan 08, 2017

You can do it using this code:

this.deletePages(this.numPages-1);

Votes

Translate

Translate
Community Expert ,
Jan 08, 2017 Jan 08, 2017

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 08, 2017 Jan 08, 2017

Copy link to clipboard

Copied

You can do it using this code:

this.deletePages(this.numPages-1);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 08, 2017 Jan 08, 2017

Copy link to clipboard

Copied

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 ????

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 09, 2017 Jan 09, 2017

Copy link to clipboard

Copied

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 27, 2017 Nov 27, 2017

Copy link to clipboard

Copied

try67​ Thanks for this! MAN! We've been trying to figure this out for days now!!!! Just one thing.. the sting you added at the bottom. This last line to your post:

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

Do we copy and paste it in the same way as we did:

this.deletePages(this.numPages-1);

because we tried it and it didn't work. Wondering what we're doing wrong?!?!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2017 Nov 27, 2017

Copy link to clipboard

Copied

Yes, you use it exactly the same. What happens when you try to use it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 27, 2017 Nov 27, 2017

Copy link to clipboard

Copied

Open the JavaScript debugging console in Acrobat and see if there are any errors.

If the PDFs have security applied you may need to remove that security before running the script.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 02, 2020 Jul 02, 2020

Copy link to clipboard

Copied

How can I teak this code to delete only first page?

I have 3 pages in each pdf. I just want to delete the first page. 

Please Help.

Thank you,

Sumana

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2020 Jul 02, 2020

Copy link to clipboard

Copied

Delete the first page:

if (this.numPages > 1) this.deletePages({nStart: 0});

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 12, 2019 Sep 12, 2019

Copy link to clipboard

Copied

Hi, can you teak this code to make it delete pages from page 10 to last page? thank you in advance.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2020 Jul 02, 2020

Copy link to clipboard

Copied

Delete from page 10 to last page:

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 10, 2021 Dec 10, 2021

Copy link to clipboard

Copied

Hello, thank you for the info. What would be the command line to delete the last 2 pages of pdfs? Thank you in advance

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 11, 2021 Dec 11, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2021 Dec 11, 2021

Copy link to clipboard

Copied

LATEST

Thank you so much. HAPPY HOLIDAYS.!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines