Skip to main content
Participant
January 20, 2023
Answered

Script to create hyperlink based on text to link to a local document

  • January 20, 2023
  • 1 reply
  • 1854 views

I want a script that would create a hyperlink based on local file names, search the document for each file name, and link it to "[file name].pdf". For example, as a footnote in the pdf, it would say "document1" and "docment2"."document1.pdf" and "document2.pdf" exist in the same folder. I want the script to search for the name of each document in turn, and in the link address just add ".pdf" to the end to hyperlink it.

 

Is this possible, and if so where could I find more info on how to do this?

 

Thanks very much!

This topic has been closed for replies.
Correct answer try67

Ah, I see thank you. If I put all of the names of the pdfs in a text file, how would I incorporate that into the Adobe script without editing the script itself each time to include the specific pdf names?


The script can be set to read the contents of that file automatically (if it's location is known, and if the script runs from a privileged context, such as a folder-level file) and use it when searching the file.

This is not a trivial task by any means, though, especially if the file-names can contain more than one word.
I've developed similar tools for my clients in the past, so if you're interested in hiring a professional to create it for you, feel free to contact me privately by clicking my user-name and then on "Send a Message".

1 reply

try67
Community Expert
Community Expert
January 20, 2023

You can only do it if the other files are also PDFs. However, how would the script know which texts are names of files, and which ones are just other words?

Participant
January 20, 2023

All good for the pdfs - all docs will be pdfs. The script would need to take the name of each file in turn in the folder, search the document for that name, and where it finds that name, hyperlink it to [pdf name].pdf

try67
Community Expert
Community Expert
January 20, 2023

That's not possible. A script in Acrobat can't access the contents of a folder. You will need to do that yourself (this is easily done using the command-line console) and then either copy & paste it into the script or read it from a text file.