Skip to main content
Participant
May 28, 2018
Answered

Javascript for deleting certain word from bookmarks in multiple PDF files

  • May 28, 2018
  • 1 reply
  • 1546 views

Hi all,

I have to bookmark multiple PDF files reflecting the file name of the document (275 files). For example, if the document name is Javascript 2018.pdf, the bookmark will be Javascript 2018.pdf (I was already able to come to this step). The only thing I do not want is that the bookmark contains the '.pdf' part. Is there a script to remove this part of the bookmark in all files at once?

I am not really familiar with Javascripts, so you help is much appreciated.

Thanks,

Maikel

This topic has been closed for replies.
Correct answer try67

Adobe Acrobat XI Pro


OK, then create an Action in the Action Wizard that executes this code and run it on your files:

if (this.bookmarkRoot.children!=null) {

    for (var i=0; i<this.bookmarkRoot.children.length; i++) {

        var bkm = this.bookmarkRoot.children;

        bkm.name = bkm.name.replace(/\.pdf$/i, "");

    }

}

Don't forget to add a Save command after the Execute JavaScript command.

1 reply

try67
Community Expert
Community Expert
May 28, 2018

Is your bookmark tree flat (ie, one level), or does it have multiple levels? If the latter, do you want to remove that term from all levels, or just the top one?

Also, to be able to process multiple files you will need Acrobat Pro. What version of Acrobat do you have?

Participant
May 28, 2018

In this case it is a flat tree, the documents only contain one bookmark so it is only for one level.

The version I use is Adobe Acrobat XI.

Maikel

try67
Community Expert
Community Expert
May 28, 2018

Adobe Acrobat XI Pro or Standard? Look under Help - About Adobe Acrobat.