Copy part of text doc and email

Hi Everyone,

I was trying this in automater but couldn’t get it to work. Here is what I’m trying to accomplish.

I use a program called Synchronize! X Plus to backup and sync files. I would like to have a script that looks at the contents of the Synchronize! X Log for a certain character “*” which it uses to note errors. The log file is located at:
Users/CurrentUser/Library/Preferences/Synchronize! X/Synchronize! X Log.

Here is a sample of how it writes in the log.
Begin Log Sample>>
8/31/06 9:36 AM Starting backup for “TiBook Work - Monday”.
8/31/06 9:39 AM Couldn’t find the disk “TiBook HD”. Synchronization cancelled.

  • Can’t find the disk “TiBook HD”.
    there was an error copying the files.

End Log Sample>>

then copy the error message and email it.

Step by Step

  1. open Synchronize! X Log with TextEdit
  2. search for “*”
  3. if found copy from “*” to next return then loop to find every instance
  4. save a copy of the log as is to the same directory and add Date & Time to filename
  5. clear the log, save and close
  6. email the log error(s) using Mail.app

Any help would be greatly appreciated.
Thanks,
Mark

Model: G5 2.0gHz DualCore Power PC
AppleScript: 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Something like this:


--property tLog : ((path to preferences folder as text) & "Synchronize! X:Synchronize! X Log")
-- if there's an extension, it must be added; it's part of the name

-- for testing:
set SynLog to "8/31/06 9:36 AM Starting backup for \"TiBook Work - Monday\".
8/31/06 9:39 AM Couldn't find the disk \"TiBook HD\". Synchronization cancelled.
* Can't find the disk \"TiBook HD\".
   there was an error copying the files."

--set SynLog to read alias tLog -- might need 'as Unicode text' here
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "*"
set parseLog to text items 2 thru -1 of SynLog
set AppleScript's text item delimiters to tid
set msg to ""
if (count parseLog) ≥ 1 then repeat with L in parseLog
	set msg to msg & contents of L
end repeat

--send the message