• 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: applescript to create multiple text files from delimited sections of one original text file?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: applescript to create multiple text files from delimited sections of one original text file?


  • Subject: Re: applescript to create multiple text files from delimited sections of one original text file?
  • From: Michelle Steiner <email@hidden>
  • Date: Sun, 8 Apr 2007 15:16:48 -0700

On Apr 8, 2007, at 2:13 PM, Erik Mikysa wrote:

I would like to figure out how I can take one text file (the output of a data merge) and automatically process it into multiple files, each containing the appropriate delimited content.  For instance, if the main original text file had the following content:

set Original_text to (read (choose file with prompt "Choose the file to process."))
set the destination to (choose folder with prompt "Choose the folder to save the files in." default location (path to documents folder)) as text

set text item delimiters to "[break-into-file-with-name:"
set the paras to the rest of the text items of the Original_text
repeat with Para in the paras
set {title, content} to breakdown(Para)
set fileRef to open for access destination & title with write permission
set eof of fileRef to 0
write content to fileRef
close access fileRef
end repeat

on breakdown(input)
set text item delimiters to "]"
return {text item 1 of input, text items 2 through end of input}
end breakdown

The reason it's "text items 2 through end of input as text" instead of "text item 2 of input" is to take into account whether there are any right brackets in the text.

The reason for "rest of" is that for some reason the first text item is a null string.  "Rest of" returns text items 2 through -1 of the list.

-- Michelle

-- 
Only in in the USA do they have a General in charge of the post office and a Secretary in charge of defense.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >applescript to create multiple text files from delimited sections of one original text file? (From: Erik Mikysa <email@hidden>)

  • Prev by Date: applescript to create multiple text files from delimited sections of one original text file?
  • Next by Date: Re: Sort a List with Integers & Letters
  • Previous by thread: applescript to create multiple text files from delimited sections of one original text file?
  • Next by thread: Folder Watcher issue
  • Index(es):
    • Date
    • Thread