🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #20747

Re: Export all stories from all chapters of book? (Applescript)

#20747
From: Shane Stanley
Date: Wed, 05 Jun 2002 07:16
59 lines
3024 bytes
in article ef8ed19.-1@WebX.aaQKaf7vad4, Aaron Andrade wrote:

> The script included on the 2.0 CD for exporting text from all stories in a
> document.... works fine.
> 
> I'd like to do the same with all documents in a book. Preferably auto-saved in
> subfolders named according to chapter (document) title, within a master folder
> of my own choosing.
> 
> Can anyone help? i'm an Applescript novice and find the ID2 scripting guide
> merely a withered carrot dangled several feet out from a lofty precipice.

This should get you started:

set myFolder to choose folder with prompt "Select a folder in which to store
the exported files"
tell application "InDesign 2.0.1"
 --Set a file extension for cross-platform compatibility (use ".txt" for
text and ".rtf" for RTF).
 set myExtension to ".rtf"
 try
  set myErrorMessage to "No books are open. Please open a book and try
again."
  set docPaths to (full name of every book content of book 1)
  if (count of docPaths) = 0 then
   set myErrorMessage to "Open a book with documents and try again."
   error
  end if
  repeat with i from 1 to count of docPaths
   open item i of docPaths
   set myDocument to document 1
   set theName to name of myDocument
   tell application "Finder"
    if not (exists folder theName of myFolder) then
     make folder at myFolder with properties {name:theName}
    end if
   end tell
   repeat with myCounter from 1 to (count stories of myDocument)
    --Name each story using the story ID.
    set myFileName to "story " & id of story myCounter of myDocument &
myExtension
    --Create the path to the export file.
    set myFilePath to (myFolder as string) & theName & ":" & myFileName
    tell story myCounter of myDocument
     --Export formats are: tagged text, text type, and RTF
     export format RTF to myFilePath without showing options
     
    end tell
   end repeat --myStoryCounter
   close myDocument saving no
  end repeat
 on error
  activate
  display dialog myErrorMessage
 end try
end tell

-- 
Shane Stanley,  sstanley@myriad-com.com.au
Technical Details
Message-ID: <B923F7F4.31E75%sstanley@myriad-com.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!newsfeed.wirehub.nl!news-out.nuthinbutnews.com!propagator-sterling!news-in.nuthinbutnews.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <ef8ed19.-1@WebX.aaQKaf7vad4>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,4d2147f4ec8ee501
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-06-05 00:37:34 PST
From: Shane Stanley <sstanley@myriad-com.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!supernews.com!newsfeed.wirehub.nl!news-out.nuthinbutnews.com!propagator-sterling!news-in.nuthinbutnews.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Export all stories from all chapters of book? (Applescript)
Message-ID: <B923F7F4.31E75%sstanley@myriad-com.com.au>
Date: Wed, 5 Jun 2002 00:16:37 -0700
References: <ef8ed19.-1@WebX.aaQKaf7vad4>
Lines: 67
User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.3
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit