On Nov 02, 2014, at 03:36, jgill <[email protected]> wrote:
> I am copying and pasting found text

______________________________________________________________________


Hey Joe,

A good rule of the thumb in automation is to never use the clipboard, unless 
it's the best tool for the job.  It's a common failure-point and/or slow-down.

This is roughly how I'd go about it.

(I've also cleaned up certain aspects of my previous script.)

-------------------------------------------------------------------------------------------
set templateFile to alias ((path to home folder as text) & 
"test_directory:BBEdit_Test_Dir:Template.txt")
set basePath to ((path to documents folder as text) & "(2014):")
tell (current date) to set newFileName to (its month as text) & " " & its year 
& ".html"
set newFilePath to basePath & newFileName

tell application "BBEdit"
  open templateFile
  tell result to save to newFilePath
  
  tell text of text document newFileName
    set foundReco to find "<div class=\"placeholder\">" options ¬
      {search mode:grep, starting at top:true, case sensitive:false}
    
    # I'm not seeing any benefit to this line; am I missing something?
    # set theResult to balance tags # == FALSE
    
    set replaceText to "<div id=\"page_main\">" & return & (contents of text of 
found object of foundReco) & "</div>"
    
    # Assuming the newly created document is the target.
    replace "(?s) This is the template for monthly sightings.*?Check in WYSIWYG 
mode and save again\\.<br>\\r" using replaceText ¬
      options {search mode:grep, starting at top:true, case sensitive:false}
  end tell
  
end tell
-------------------------------------------------------------------------------------------

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to