Automator: Search the contents of PDF's in a specific folder

Hey Everyone. I am looking to automate something that I can already do in finder. Just looking for a quicker option as its something I need to do regularly.


I have a folder full of PDF's. I repeatedly need to search the contents of all of the PDF's in this one folder. The folder never changes, but the keyword or query changes.


I'd like a way to run an automator application or apple script that will ask me for text, and then search this one folder for that text. Then it would filter the results in finder to show me only the PDF's that contain that keyword. I don't need it to open any of the files, but I just want to see a finder window with them.


Anyone know if this can be done with automator? I know they have a "Search PDF" option, but I can't seem to make the search keyword variable.


Appreciate your help.

MacBook Pro with Retina display, OS X El Capitan (10.11.3)

Posted on Jan 30, 2016 9:40 PM

Reply
5 replies

Jan 31, 2016 5:38 AM in response to Scaldo

Try the "Spotlight action", followed by "Reveal Finder Items"


A search for : "Last updated 2012", in one folder, has revealed 25 files:

User uploaded file

Nb. Check the box : Show this action when the workflow runs.


& A search for : "AudioUnit Validation", in the same folder has revealed only one file:

User uploaded file

You could then save the workflow as an Application.





Jan 31, 2016 6:03 AM in response to balsa2

Awesome balsa2! Appreciate your help. That works. I have actually never used the "spotlight" option before. Embarrassing.


Here is what happens, and 2 things that would be awesome to improve on further.


First.

When the window pops up, the curser is ready to go so I can type, but I have to click on the "Continue" button. Is there any way of me bing able to just use the keyboard to hit enter?


Better than this though, and my ideal solution, would be to eliminate a step here. I use Alfred.app. I was hoping to create a workflow that I could activate with Alfred, and the work I am searching for would also be typed into Alfred. Is there any way for this workflow to use something like "Get Specified Text" and put it into the "Spotlight" search option?


Second.

Any way of filtering the results in finder down to just show the ones containing that word? Currently it shows all files and highlights the results. This is really not as big of a deal as the first question. However, if you know an easy solution, that would be a bonus.

User uploaded file


Appreciate your help!

Jan 31, 2016 8:34 AM in response to Scaldo

Add the "Ask for Text" & "Set Value of Variable" actions.

Click on Variable (red arrow) then New variable..... , give it a name.

Drag the Variable you have named, at the bottom of the screen (circled in green) into the "Spotlight" Search for : box.

& Uncheck Show this action when the workflow runs (circled in red)

User uploaded file

You should get a dialog box, with text input, the default button is "OK", so press the return key, after typing your search keyword.

Jan 31, 2016 9:06 AM in response to Scaldo

Sorry, please ignore my last reply, I left something out !


Add the "Ask for Text" & "Set Value of Variable" actions.

Click on Variable (red arrow) then New variable..... , give it a name.

Drag the Variable you have named, at the bottom of the screen (circled in green) into the "Spotlight" Search for : box.

Check the Require an answer box, in the "Ask for Text" action (circled in blue)

& Uncheck Show this action when the workflow runs box (circled in red) in the "Spotlight" action.

User uploaded file

You should get a dialog box, with text input, the default button is "OK", so press the return key, after typing your search keyword.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Automator: Search the contents of PDF's in a specific folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.