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

Javascript for deleting certain word from bookmarks in multiple PDF files

New Here ,
May 28, 2018 May 28, 2018

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

TOPICS
Acrobat SDK and JavaScript , Windows
1.6K
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

correct answers 1 Correct answer

Community Expert , May 28, 2018 May 28, 2018

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.

Translate
Community Expert ,
May 28, 2018 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?

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 ,
May 28, 2018 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

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 ,
May 28, 2018 May 28, 2018

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

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 ,
May 28, 2018 May 28, 2018

Adobe Acrobat XI Pro

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 ,
May 28, 2018 May 28, 2018

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.

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 ,
May 28, 2018 May 28, 2018
LATEST

This works perfectly, many thanks!

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