![]() |
Automator or other script experts? - Printable Version +- MacResource (https://forums.macresource.com) +-- Forum: My Category (https://forums.macresource.com/forumdisplay.php?fid=1) +--- Forum: Tips and Deals (https://forums.macresource.com/forumdisplay.php?fid=3) +--- Thread: Automator or other script experts? (/showthread.php?tid=236424) Pages:
1
2
|
Automator or other script experts? - deckeda - 01-17-2020 I have a folder of PDFs I'd like text searched for. (Each PDF has searchable text.) I want to copy or enter the text and then have each PDF searched for that string (not the separate words). I want the results to show me which PDFs have the results if possible as a list, or opening/leaving the PDFs open is fine too. The string is a phrase, usually. Maybe just an acronym. But whatever, its a few words appearing in a certain order. I see that Automator includes a thing for searching PDF "from Spotlight metadata" but don't know anything about how to glue together what makes the actions work. [Edit] I'm using macOS' Preview to read the PDFs. Re: Automator or other script experts? - deckeda - 01-17-2020 It's occurred to me a simple script could be more trouble than it's worth. I still have to open/search each PDF that would have the string because what I need from the PDF is usually a paragraph following the search string IF its present. Example, I have a definition to look for. Out of say, 10 PDFs, one or two should have it. I open each PDF and search within it. When I find it I copy the word's or phrase's definition and paste into something else and move on to the next PDF to see if it's also in that one etc. Re: Automator or other script experts? - rjmacs - 01-17-2020 Is Spotlight search in Finder not adequate? It's basic basic, but its metadata is what you'd be using in a script, and this already has a decent UI. ![]() Re: Automator or other script experts? - deckeda - 01-17-2020 Thanks rj, yes that'll do it but now I'm further realizing it's not enough. For example, if I search for "Energy management" one or two of the docs will have that as a definition (along with however they define energy management.) But every document has those words, returning all PDFs, most of which are irrelevant because they are merely using the words "energy" and "management" together as part of a sentence or whatever (or maybe not even together.) The Spotlight results would need to show me what page(s) the text resides and how it looks; otherwise I'm back to just opening them one-by-one and running the same search each time. Like now ![]() ***************** The good news is that I'm being paid well for this insanely mundane and tedious task, and by the hour, but I thought I'd still try to to speed it up! Re: Automator or other script experts? - freeradical - 01-17-2020 Sounds like a job for BBEdit. Re: Automator or other script experts? - Marc Anthony - 01-18-2020 Assuming you have consistently formatted documents, this returns paths hit by your search term and the text from the following paragraph. set searchTerm to (display dialogInput the search string:default answerenergy management)'s text returned Re: Automator or other script experts? - rjmacs - 01-18-2020 Free consulting! This place rocks. Re: Automator or other script experts? - deckeda - 01-18-2020 Marc Anthony wrote: Thanks Marc! The docs are consistently formatted unfortunately. I did run it from within Script Editor (didn't even realize that was still around) and it stopped at the shell script with a "non-zero status." I appreciate it though. Re: Automator or other script experts? - Marc Anthony - 01-18-2020 You're welcome. That error means it was pointed at a folder that didn't contain at least one file with the search term. Re: Automator or other script experts? - deckeda - 01-18-2020 Marc Anthony wrote: That's my problem. "Energy Management" was indeed included on a page with other definition terms. Here's a partial screenshot of what the particular PDF looks like after using Preview's search field: ![]() I realize that alone doesn't prove I pointed the script at the folder. |