Javascript for deleting certain word from bookmarks in multiple PDF files

May 28, 2018

Copy link to clipboard

Copied

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

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.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

200

Likes

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

Javascript for deleting certain word from bookmarks in multiple PDF files

May 28, 2018

Copy link to clipboard

Copied

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

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.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

201

Likes

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

Copy link to clipboard

Copied

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?

Likes

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
Reply
Loading...
May 28, 2018 0
May 28, 2018

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
May 28, 2018 0
May 28, 2018

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
May 28, 2018 0
May 28, 2018

Copy link to clipboard

Copied

Adobe Acrobat XI Pro

Likes

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
Reply
Loading...
May 28, 2018 0
May 28, 2018

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
May 28, 2018 0
May 28, 2018

Copy link to clipboard

Copied

This works perfectly, many thanks!

Likes

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
Reply
Loading...
May 28, 2018 0