01-18-2020, 10:36 PM
You may want to try this modification. I think I left out an-a option for binary files. While the text in your output PDF may appear readable in its composite form, the "text" within it may not be so clean. I just tried this on a sample PDF with one visible instance of the searchTerm, but there are actually 20 or so in the file's data contents. Best of luck to you.
set searchTerm to (display dialogInput the search string:default answersuspect)'s text returned
(do shell scriptfgrep -iraA1& searchTerm's quoted form & space & (choose folder with promptLocate the folder containing the files to be searched.)'s POSIX path's quoted form)