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

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

New Here ,
Jan 08, 2017 Jan 08, 2017

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
12.5K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 08, 2017 Jan 08, 2017

You can do it using this code:

this.deletePages(this.numPages-1);

View solution in original post

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

You can do it using this code:

this.deletePages(this.numPages-1);

Translate
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

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

Translate
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

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

Translate
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
Contributor ,
Nov 27, 2017 Nov 27, 2017

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

Translate
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

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

Translate
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

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.

Translate
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

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

 

Translate
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

Delete the first page:

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


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
Hi, can you teak this code to make it delete pages from page 10 to last page? thank you in advance.
Translate
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

Delete from page 10 to last page:

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


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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

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

 

Translate
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

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


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
LATEST

Thank you so much. HAPPY HOLIDAYS.!

Translate
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