Skip to main content
Participant
September 19, 2016
Question

Rename PDF based on content?

  • September 19, 2016
  • 2 replies
  • 17696 views

Is there a Javascript available that automatically renames a PDF based on the content?

Some fields in the PDF should be reflected in the PDF name.

This topic has been closed for replies.

2 replies

Participant
January 8, 2019

I know this is an old thread, but it still shows an unanswered. Renaming of PDF files with JavaScript is doable by very tedious especially if you need to extract text from a specific location(s). There is also a performance issue since working with page content in JavaScript is not fast. Using a plug-in with a user interface can be more convenient especially when dealing with this task on a regular basis. Here is a link to a tutorial that shows how to bulk rename PDF files using text from the document with AutoSplit plug-in: Automatic Renaming of PDF Files . Text can be extracted from specific page location(s) or by text search (using text patterns such as SSN, account numbers and etc.). This is a commercial plug-in for Adobe Acrobat, not a JavaScript.

try67
Community Expert
Community Expert
January 8, 2019

How is renaming PDF files with JS doable, tedious or not?

try67
Community Expert
Community Expert
January 8, 2019

Sorry, I did not understand your question first. You are absolutely correct, JavaScript cannot rename an existing file, only to create new ones. I was under assumption that creating a new file with a different name is really counts as renaming, since there is no other option available in JS. I do not think that this is actually a bad thing, because it probably saved a lot of user files from being lost, accidentally overwritten or given the same name. In my opinion, automatic file renaming without a user review/confirmation step is kind of dangerous. If input files layout/content have been changed from what the script is designed to do, then script can no longer extract the correct text, and then consequences are grim. By saving the renamed files in a different location, the originals are preserved and can be always used to roll-back the changes or re-running the renaming algorithm. Better safe then sorry.


I agree. Just wanted to make sure there isn't some kind of hidden feature I was not aware of that allowed it...

Inspiring
September 19, 2016

No, since you have the PDF open, you cannot rename it.

What content are you going to use?

It could be saved under a new name using  form fields or the PDF properties of key words, subject, or title if the properties are field in for the PDF. But this type of coding will require some special code in folders.

Participant
September 19, 2016

All my files have key words on the same place. And saving them under a new correct name is what im looking for. Can I send you an example of the pdf that would need to be renamed?

Inspiring
September 19, 2016

We are here to help you with script problems not write the entire script for you.

https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

How to Save a PDF with Acrobat JavaScript

by Thom Parker will get you started with the folder level script for saving using JavaScript. You can use the document object's info.Keywords method to get