Copy link to clipboard
Copied
I have a set of files that I need to compile into a pdf. They are named in a way that ensures they are in the correct order in the folder for how I want them to be bookmarked in my pdf. The names of the bookmarks I want are all the characters after the last _ in the file name.
Ex.
20220514_name_my bookmark name.doc
20220516_name2_my 2nd bookmark name.doc
20220518_name3_my 3rd bookmark name.pdf
20220522_name4_my 4th bookmark name.doc
When I compile these, the bookmarks are the complete file names, but I would like them to be
my bookmark name
my 2nd bookmark name
my 3rd bookmark name
my 4th bookmark name
Is there a way to rename all of the bookmarks once teh pdf is compiled by trimming off everything prior to the name I would like for the bookmark? I don't want to have to click on each individual bookmark to rename them.
Or, is there a way to change the names during the compiling process?
There are at least 20 files that are getting compiled for each pdf and this is something I have to do often so would like a quick way to do it.
I am not a programmer, but I have worked with python, VBA, and minorly with other languages. I could probably adjust someones JAVA script or some other language if there was code out there to do something like this (with a little documentation). I'm just not sure where to look.
Thank you for any help you can give me.
Copy link to clipboard
Copied
Hi,
Try this script:
function renameBookmark(bkm,level) {
var theName=bkm.name.split("_");
try {bkm.name=theName[2].replace(/(.doc|.pdf)$/i,"")} catch(e) {}
if (bkm.children!=null) for (var i=0; i<bkm.children.length; i++) renameBookmark(bkm.children[i],level++);
}
renameBookmark(this.bookmarkRoot,0);
@+
Copy link to clipboard
Copied
Thank you! This worked perfectly.