• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: text item delimiter-resolved.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: text item delimiter-resolved.


  • Subject: RE: text item delimiter-resolved.
  • From: "Ruby Madraswala" <email@hidden>
  • Date: Mon, 2 May 2005 08:44:18 -0400
  • Thread-topic: text item delimiter

Thanks all.

 

I used the script example given below and it worked.

 

I did get quite a few suggestions to use “sed”, that’s so new for me. I did not find any reference to this command in Applescript The Definitive Guide book. Is this new or you just know by experience?

 

Thanks again.

Ruby

 

-----Original Message-----
From: Mark J. Reed [mailto:email@hidden]
Sent: Friday, April 29, 2005 11:01 AM
To: Ruby Madraswala
Cc: Applescript Users
Subject: Re: text item delimiter

 

That won't work; even if the multiple-delimiter thing worked and the file text were split up properly, you don't have any way of knowing which text items had a 1 between them, which had a 2, etc; you'd probably end up with nothing but 'a's for delimiters in the new file.

You have to do it one at a time:

set fileText to (read file ":path:to:some:file.txt")
set fromList to {"1", "2", "3", "4"}
set toList to {"a", "b", "c", "d"}
set oldDelims to AppleScript's text item delimiters
repeat with i from 1 to count fromList
    set AppleScript's text item delimiters to fromList's item i
    set wordList to text items of fileText
    set AppleScript's text item delimiters to toList's item i
    set fileText to wordList as text
end repeat
set AppleScript's text item delimiters to oldDelims

On 4/29/05, Ruby Madraswala <email@hidden> wrote:


Is this doable using text item delimiters, I tried it's not working. All I want to do is search a text file replace all occurrence of 1 to a, 2 to b.........................

Set FileText to read file tmptw from 1
Set Applescript's text item delimiters to {"1","2","3","4"}
Set wordlist to text items of FileText
Set Applescript's text item delimiters to {"a","b","c","d"}
Set FileText to wordlist as text

Ruby

_______________________________________________
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




--
Mark J. Reed < email@hidden>

 _______________________________________________
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

  • Follow-Ups:
    • Re: text item delimiter-resolved.
      • From: kai <email@hidden>
    • Re: text item delimiter-resolved.
      • From: Gnarlodious <email@hidden>
  • Prev by Date: [Tiger] Script Editor bug?
  • Next by Date: Re: text item delimiter-resolved.
  • Previous by thread: [Tiger] Script Editor bug?
  • Next by thread: Re: text item delimiter-resolved.
  • Index(es):
    • Date
    • Thread