Re: read a specific word of a text file
Re: read a specific word of a text file
- Subject: Re: read a specific word of a text file
- From: Michelle Steiner <email@hidden>
- Date: Wed, 22 Sep 2004 23:39:24 -0700
On Sep 22, 2004, at 11:12 PM, Jasneet Kaur wrote:
I need to read a specific word of a text file (in Mac's text editor)
and
then replace it with another word.
(that is, the kind of action we do with the "Replace All" option in
notepad
when using windows)
So could you please help me do that using AppleScript.
Here is one way.
set x to text returned of (display dialog "what word do you wish to
replace?" default answer "")
set y to text returned of (display dialog "what word do you wish to
replace it with?" default answer "")
set foo to open for access (choose file) with write permission
set bar to read foo
set {tid, text item delimiters} to {text item delimiters, x}
set barlist to text items of bar
set text item delimiters to y
set z to barlist as text
set text item delimiters to tid
set eof of foo to 0
write z to foo
close access foo
--
"Colorless green ideas sleep furiously."
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden