applescript - Apple Script : Cleaning textedit text -
i want clear text textedit text half working me
tell application "textedit" set documenttext text of document 1 set {oldtid, text item delimiters} {my text item delimiters, "administration"} set textbits text items of documenttext set text item delimiters "" set text of document 1 textbits text set text item delimiters oldtid set documenttext text of document 1 set {oldtid, text item delimiters} {my text item delimiters, "new search"} set textbits text items of documenttext set text item delimiters "" set text of document 1 textbits text set text item delimiters oldtid set documenttext text of document 1 set {oldtid, text item delimiters} {my text item delimiters, "advanced"} set textbits text items of documenttext set text item delimiters "" set text of document 1 textbits text set text item delimiters oldtid set documenttext text of document 1 set {oldtid, text item delimiters} {my text item delimiters, "tips"} set textbits text items of documenttext set text item delimiters "" set text of document 1 textbits text set text item delimiters oldtid end tell
for reason "new search" still on text document. possible otherwise keep text line 2 3 example?
kind regards.
multiple text item delimiter calls can tricky applescript. try this:
tell application "textedit" set documenttext text of document 1 tell application "textedit" set text of document 1 removethis(documenttext, {"administration", "new search", "advanced", "tips"}) removethis(txt, termlist) repeat eachterm in termlist set {oldtid, applescript's text item delimiters} {applescript's text item delimiters, (eachterm text)} set textbits text items of txt set applescript's text item delimiters oldtid set txt (textbits text) end repeat return txt end removethis
in way, can define list of terms sifted through, , not worry coding details.
Comments
Post a Comment