Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automator or other script experts?
#8
Marc Anthony wrote:
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 dialog 
Input the search string:
default answer
energy management
)'s text returned
set itsPathandpostPara to {}
set found to (do shell script
fgrep -irA1
& searchTerm's quoted form & space & (choose folder with prompt
Locate the folder containing the files to be searched.
)'s POSIX path's quoted form)
set text item delimiters to
-
repeat with focus from 2 to (count found's paragraphs) by 3
set itsPathandpostPara's end to {found's paragraph focus's text item 1, found's paragraph focus's text item 2} & return
end repeat
set text item delimiters to return
set itsPathandpostPara to itsPathandpostPara as text
set text item delimiters to
itsPathandpostPara

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.
Reply


Messages In This Thread
Automator or other script experts? - by deckeda - 01-17-2020, 08:33 PM
Re: Automator or other script experts? - by deckeda - 01-18-2020, 08:28 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)