Skip to main content
justinm39103228
Participant
April 19, 2016
Question

Batch Sequence - Renaming Bookmarks

  • April 19, 2016
  • 2 replies
  • 7657 views

Hi,

Complete JS noob here. Whenever I have an issue I just google scripts and copy and paste them and adjust them accordingly - I have never written one on my own.

So if anyone is feeling nice enough to write an entire script that I can just copy and paste (and tweak) for this, THANK YOU!

So what I want to do is to automate the sequential renaming of bookmarks. I have created a PDF consisting of other PDFs and have used the built-in Acrobat features to automatically create bookmarks. Instead of having to manually rename all these bookmarks, is there a script out there that can do this? I need to make the bookmarks sequential, for example:

TAB 1

TAB 2

TAB 3

TAB 4

The bookmarks are already in the right spots, all I need to do is rename them similarly to the naming convention used in this example.

2 replies

Participant
July 5, 2018

This is such a good question. Have you found the answer ?

BarlaeDC
Community Expert
Community Expert
July 5, 2018

Hi,

 

It is pretty simple to do this, the documentation pretty much gives you all the code, but here you go

 

 

var myBookMarks = this.bookmarkRoot;

for ( var i = 0; i < myBookMarks.children.length; i++)

{

    myBookMarks.children[i].name = "Tab" + i;

}

 

Just add this to a button and you are good to go, you could even make it a application level script but you would need to change line 1 as the this object wouldn't point to a document.

 

Hope this helps

 

Malcolm

descentfan1975
Participating Frequently
September 23, 2022

I know this is an old question, but I have a similar issue. I want to strip out parts of all the bookmarks. See the attached file....I want to remove the "22115-Safeway Manning CFS SHOP PLANS-" from every bookmark and just keep the S101, S201, etc.

 

Inspiring
April 19, 2016

When I have combined PDFs I always get an additional bookmark with the source PDF's name. How do you want to handle this bookmark?

It is possible to remove these bookmarks with JavaScript.

http://www.planetpdf.com/developer/article.asp?ContentID=RemovingfilenamebookmarkscreatedbyAcrobat&gid=6881

Removing filename bookmarks created by Acrobat

The script puts all the bookmarks into an array and only adds bookmarks that do  not have a file name ending in ".pdf". You could rename the bookmark as part of the process adding the bookmark to the array.