Replacing a colon and tab in TextEdit?

Hi all,

I wonder if some kind soul could help me?

I am working on an automator workflow (for 10.4 Tiger) that strips out one line of an iCal event and saves it as a PlainText TextEdit document on the desktop. Ideally I don’t want this text file saved but I am having to do this so it can be merged with more text to create an overdue invoice e-mail.

The automator workflow is pretty straightforward but I am struggling with trying to generate an AppleScript that removes certain characters from the .txt file.

For example, iCal generates a file with the following text:

Summary: Invoice 1/08 is overdue

Through this forum I found a simple script to find and replace words, but it won’t work with the colon and tab after Summary. I want the text "Summary: " to be replaced with nothing “”.

Here is the script I’m trying to use:

tell application "TextEdit" to tell document 1 to set every word where it is "summary:	" to ""

Many thanks if you can help, I’m lost,



try this

set t to "Summary:	Invoice 1/08 is overdue"

set {TID, text item delimiters} to {text item delimiters, "Summary:" & tab}
set t to text items of t
set text item delimiters to TID
set t to t as text
--> "Invoice 1/08 is overdue"

PS: TextEdit is not needed, to find and replace plain text

Many thanks for such a quick response, Stefan,

Using the script you provided from Script Editor generates what appears to be a correct result, but when I add the script into the Automator workflow, it doesn’t generate the same result:

From this: “Invoice 1/08 is overdue”
To this: {“Summary: Invoice 1/08 for £637.50 is now overdue”}

Also, I’m only wanting to find and change Summary: (plus the tab) as the text after this will change every single time.

Can this be done?



Can you please post the Automator actions you are using (perhaps also with their options)

Hi again,

I’ve made some progress and just about circumvented any need for a textedit file.

The automator events are as follows:

  1. Get specified iCal items

    • links to Invoices Overdue calendar
  2. Event Summary

    • For Today
  3. Filter Paragraphs

    • Return paragraphs that contain: is now overdue
  4. View Results

  5. Copy to Clipboard

  6. New Mail Message

    • To: Subject: and Message: filled in but space left for event summary to be pasted in
  7. Run Applescript

on run {input, parameters}
		tell application "System Events"
			keystroke "v" using command down
		end tell
	on error errMsg number errNum
		set AppleScript's text item delimiters to ASTID
		display dialog "Error " & errNum & return & return & errMsg with icon caution buttons {"Cancel"} default button 1
	end try
	return input
end run

So in essence, anything with the words invoice overdue are copied to the clipboard, from iCal, and a new Mail message opens up with template text already in there and the invoice overdue text is pasted above this template text.

I did find another little script that now removes "Summary: " but I can’t get it to amend either the event summary before or after it’s copied to the clipboard, or when it’s in the new mail message window.

	set t to "summary:	"
	set s to "summary:	"
	set r to ""
	set utid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {s}
	set temp_list to text items of t
	set AppleScript's text item delimiters to {r}
	set t to temp_list as string
	set AppleScript's text item delimiters to utid
	return t

Thanks for your continued help,


this Run AppleScript action after the Filter Paragraphs action removes “Summary:” from all found lines

on run {input, parameters}
	repeat with i in input
		set {TID, text item delimiters} to {text item delimiters, "Summary:" & tab}
		set t to text items of i
		set text item delimiters to TID
		set contents of i to t as text
	end repeat
	return input
end run

I’m not very familiar with Automator, because I usually do everything directly in AppleScript


Thanks ever so much, Stefan. It now finally works how I envisaged. All set for tomorrow to tell my client they’re late, again!