// this code taken from http://bbs.applescript.net/viewtopic.php?id=20330
do shell script "grep string /Users/username/Desktop/QSPresetQSFileTagsPlugIn.qsindex | awk {'print $1'}"
set theTags to result
set newText to switchText of theTags from "qs.tag.file" to ""
to switchText of currentText from SearchString to ReplaceString -- the handler
set storedDelimiters to AppleScript's text item delimiters
-- this simply stores the current value of AppleScript's AppleScript's text item delimiters
-- so they can be restored later (thus helping to avoid potential problems elsewhere).
-- Remember, we always set them back to what they were.
set AppleScript's text item delimiters to SearchString
-- AppleScript's AppleScript's text item delimiters are now set to "Purple"
set currentText to currentText's text items -- note we have changed currentText's value
-- create a list of text items from the original text, separated at the points where the
-- current text item delimiter ("Purple") appeared.
--> {"What, ", " Shoes?"} - Note that the spaces and punctuation are retained.
set AppleScript's text item delimiters to ReplaceString
-- AppleScript's AppleScript's text item delimiters are now set to "Green"
set currentText to currentText as Unicode text
-- coerce the list {"What, ", " Shoes?"} to Unicode text. This operation will also
-- insert the current value of AppleScript's AppleScript's text item delimiters ("Green")
-- between each of the listed items
--> "What, Green Shoes?"
set AppleScript's text item delimiters to storedDelimiters
-- restore the value of AppleScript's AppleScript's text item delimiters
-- to whatever they were on entering the subroutine. Remember that a call to this
-- might have been made from within a section of script that had the TIDs set to
-- something else. Hand the result back with the TIDs as they were.
currentText
-- return the now modified text (and restored TIDs) -- "What, Green Shoes?"
set this_text to currentText
set new_text to ""
--Loop through paragraphs of old text
repeat with myPara in paragraphs of this_text
--Check for paragraph’s contents in new text
--If not there add new text to end of new text
if new_text does not contain myPara then set new_text to new_text & myPara & return
end repeat
--Remove final return
set new_text to (characters 1 thru -2 of new_text) as text
end switchText -- the end of the handler.