tell application "TextEdit"
activate
--set myText to paragraph 1 of document "fmp.csv"
read line 1 of paragraph 1 of document "fmp.csv"
end tell
The following script does work to build the page correctly if I put only one record into the fmp.csv file, then saves it as the original file name. I need to have it save a unique file name as well into the same folder for each record/page that InDesign creates as well as distinguishing each record, importing it, then going on to the next record from the original "fmp.csv" file. Doesn't necessarily have to reflect the record, as long as the previous file name is not overwritten.
-- Find out where the InDesign document is, and from that compute
-- the containing folder .
set inndDoc to (choose file with prompt "Where is “Site-audit-IDf”?")
tell application "Finder"
-- Extract the folder name
set docFolder to (container of inndDoc) as text
end tell
tell application "InDesign CS"
-- You must *always* activate InDesign before importing (i.e., bring it
-- to the front), or InData will hang after finishing until you do so.
activate
-- Open our document.
open inndDoc
-- Import fmpro list "fmpt.csv" into the audit-story linked frames from the same folder
-- using the “audit-proto” prototype.
import data from file (docFolder & "fmpt.csv") ¬
into story "audit-story" using prototype story "audit-proto"
close document 1 saving yes
end tell
On May 22, 2005, at 3:33 AM, Emmanuel wrote:
At 7:18 PM -0400 5/21/05, Avi Learner wrote:
I am trying to write a script to flow text from a text file with 100 or so records into an InDesign Template. I have the basic open script working with one record (from a text file) and it saves with it's original name. I want to import all the records creating separate pages for each record, and then create a unique filename for each save. It would be cool to parse the file name (to be saved with the InDesign layout) from one of the text frames (columns) of each record.
My scripting skills are primitive, and I cannot find anything on the InData sight like any other sample scripts, that repeat. I cannot figure out how to script a line copy from texedit.
tell application "TextEdit"
activate
set myText to paragraph of document "fmp.csv"
end tell
returns the entire file, when I only want to copy one "line" at a time to the clipboard.
Maybe it will work better if you specify an index for the paragraph, such as:
set myText to paragraph 1 of document "fmp.csv"
Also, if what you want is to extract paragraphs from a string, maybe you don't need any application for that: AppleScript can read files by itself. Check the entry for "read" in Standard Additions' dictionary.
Emmanuel