Opening several .PDFs located in different nested folders

Explorer ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

I'm not sure if this would be the appropriate forum for this question so let me know if it's better to put it in another discussion board! My main concern is that this might be more easily done in Powershell, and I just don't want to go that route, I'd rather keep it contained within Acrobat so that If I'm not the person doing the paperwork then it's a bit less intimidating for less tech savvy folk who don't know what a terminal looks like.

I'm wanting to create a script I can run that would allow me to enter in names of several files and have Adobe open them all up either one by one or all at once. Here's the situation:

I have 6 folders, all of which have a dozen or more nested folders inside that are numbered, and tons of .PDFs inside those various child folders based on the .PDF name. These .PDFs have a naming convention according to which parent folder and child folder they're in, for example:

In folder 1, all .pdf names begin with "ES-" followed by a number 1-99, or 100-199, or...

in folder 2, all .pdf names begin with "FS-" followed by a number 1-99, or 100-199, or...

etc...

So the beginning of the name ("ES-") is determined by the parent folder and the number range is decided by the child folder.

I want to put some script together so I can choose which parent folder to start the search in via app.response prompt (or something equivalent) and then search for the numbers I input into a second prompt recursively so it can dig through the dozens of child folders and find the correct file.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

213

Likes

translate

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
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Nov 28, 2018 Nov 28, 2018
A script can't open a file if it doesn't know its full path and name. So the only way to do what you describe is by trial-and-error, ie going over all the possible file-names and trying to open them, one by one. This is not a simple scripting task, but it's certainly doable.Basically you just need to write a loop that goes over the file-names and then use the openDoc method to try and open them.

Likes

translate

Translate

Translate
Most Valuable Participant ,
Nov 28, 2018 Nov 28, 2018

Copy link to clipboard

Copied

A script can't open a file if it doesn't know its full path and name. So the only way to do what you describe is by trial-and-error, ie going over all the possible file-names and trying to open them, one by one. This is not a simple scripting task, but it's certainly doable.

Basically you just need to write a loop that goes over the file-names and then use the openDoc method to try and open them.

Likes

translate

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
community guidelines
Explorer ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

So there is no recursive search in acrobat's JS then? Bummer. To Powershell it is, then!

Likes

translate

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
community guidelines
Most Valuable Participant ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

There's no search, period.

Likes

translate

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
community guidelines
Explorer ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

Oh, that's what you were saying! Thanks for the help.

Likes

translate

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
community guidelines
Most Valuable Participant ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

What I was saying is that if the file-path and name are completely predictable then you can try it.

For example, let's say you have a root folder called C:\Files\ and underneath it there can be folders called "1", "2", "3", etc. with files in each one called "1.pdf", "2.pdf", "3.pdf", etc. You can write a function that will traverse this entire (supposed) folder path, attempting to open each possible combination, and it can even be recursive. Of course, you will need to define some kind of stop condition, or it will end up in an infinite loop.

Likes

translate

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
community guidelines
Adobe Community Professional ,
Nov 29, 2018 Nov 29, 2018

Copy link to clipboard

Copied

You don't want to control Acrobat using Powershell on "tons" of PDF files. It's going to hang or crash or hang and then crash. In either case you're going to end up having to manually figure out which PDF files got processed before the crash.

Rethink your solution.

Likes

translate

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
community guidelines