Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automator or other script experts?
#6
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
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 Marc Anthony - 01-18-2020, 02:46 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)