Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Export all stories script

222 views
Skip to first unread message

C...@adobeforums.com

unread,
May 18, 2004, 9:33:44 AM5/18/04
to
Hi,

I found a script on the Indesign CD that enables you to export all stories (ExportAllStories.js)

When you export the all the stories it gives each file a name e.g
StoryID21665.rtf

I need to translated all these files and I would like to know if there is any tool or script that could import them all again so that I wouldn't have to do it one by one.

Also, is it possible for me to change the StoryID before I export so that could maybe call the first story
StoryID1.rtf
instead of
StoryID21665.rtf

If anyone knows of any other scripts that allow you to import export stories in batches i would also be grateful to hear about them

CP

cont...@adobeforums.com

unread,
May 18, 2004, 11:07:10 AM5/18/04
to
I can see from the JS code that it gets the number from "myID"

}
myFileName = "StoryID" + myID + myExtension;
myFilePath = myFolder + "/" + myFileName;
myFile = new File(myFilePath);
myStory.exportFile(myFormat, myFile);
}

But I don't know how you would change it.

Richard_...@adobeforums.com

unread,
May 18, 2004, 12:46:14 PM5/18/04
to
I have a script like that, which exports then link each story back so it is only to update through the links palette. It is AppleScript only though and currently uses a different naming convention, based on the first words of the story. I made it for a specific customer and therefore would prefer not to post the code here. If you are interested, feel free to mail me at richard dot ronnback at bredband dot net

Shane_...@adobeforums.com

unread,
May 18, 2004, 6:24:49 PM5/18/04
to
On May 18, 2004, at 11:33 PM, CP1 wrote:

> I need to translated all these files and I would like to know if there
> is any tool or script that could import them all again so that I
> wouldn't have to do it one by one.

I posted an AppleScript version here a while back.


>
> Also, is it possible for me to change the StoryID before I export so
> that could maybe call the first story
> StoryID1.rtf
> instead of
> StoryID21665.rtf

Not really.

--
Shane Stanley <ssta...@myriad-com.com.au>

Morga...@adobeforums.com

unread,
May 19, 2004, 11:45:49 AM5/19/04
to
Search for this thread "Exporting InDesignCS Text and Reimporting Translated Text" and it will give some answers for reimporting the stories that are exported by the ExportAllStories script. You'll find the reimport script that Shane wrote, which works very well. This is the thread to which Shane is referring. There is a better way to localize I have become aware of which is to export using XML, have the translation done in the morphon XML editor (which is free by the way at www.morphon.com), and then reimport the XML document into IDCS. I hope this helps.
Morgan

cont...@adobeforums.com

unread,
May 19, 2004, 2:48:48 PM5/19/04
to
Hi,

I searched and found the code but i have been working with the .js script that comes with the IndesignCS CD and i am working in PC. So the MAC script doesn't really help.

Does anyone have a script for PC

cont...@adobeforums.com

unread,
May 19, 2004, 4:54:48 PM5/19/04
to
I found something that Ole had proposed in an earlier thread but as a total beginner i don't really understand how to implement it with the script on the Indesign CS CD.

"The Story object, oddly enough, doesn't have a Place method. But you can replace the text of the story using something like this:"

Rem Given a reference to a story "myStory" and a file path "myFileName"
myStory.Texts.Item(1).Place myFileName

Can anyone help me out here?

CP

Olav_...@adobeforums.com

unread,
May 19, 2004, 6:27:42 PM5/19/04
to
Hi contactcp--

The example you've cited is VBScript; if you're working with JavaScript, you'll need to change a few things. JavaScript is case sensitive, so:

myStory.texts.item(0).place(File(myFileName));

The point of tagging each story with the id of the story on export was to make possible exactly what you're talking about--exporting, then re-importing all of the text. The nice thing about using the ID property of the story in the name of the file is that the ID is unique--we can go back to the original document, find a story, check its ID, and we then know which exported file should replace it. We can't do that if we use the index, because the index of the story can change.

Thanks,

Ole

cont...@adobeforums.com

unread,
May 20, 2004, 3:53:36 AM5/20/04
to
Hi Ole,

Do I just add the code to the last line of the ExportAllStories script on the CD like below or am I misunderstanding something?:

myFileName = "StoryID" + myID + myExtension;
myFilePath = myFolder + "/" + myFileName;
myFile = new File(myFilePath);
myStory.exportFile(myFormat, myFile);

myStory.texts.item(0).place(File(myFileName));
}
}

CP

Olav_...@adobeforums.com

unread,
May 20, 2004, 2:49:52 PM5/20/04
to
CP--

That would replace the text of the first story with the text of the exported story over and over again. I don't think that's what you want to do--what I think you want to do is:

1. Export all of the stories.
2. Translate all of the exported stories, saving back to the same file names.
3. Replace the stories in the document with the translated versions.

Right?

If this is the case, you'd use the ExportAllStories script, then use another script to replace the stories after they are translated. If that's what you want, I can post an example.

Thanks,

Ole

cont...@adobeforums.com

unread,
May 20, 2004, 5:16:39 PM5/20/04
to
Hi Ole

Yes please.

I have heard that you can export all stories and then link the files after export.So once you have translated you can just update the links. Is that what your code does?

Anyway the code will still be appreciated.

CP

Olav_...@adobeforums.com

unread,
May 21, 2004, 5:44:13 AM5/21/04
to
CP--

It could! That's what I'll have it do in the example.

Note, however, that if you choose to export as plain text, you'll lose all formatting when you update the link; if you use RTF, some formatting might not be retained, but it's a better choice. Tagged Text will retain all of the formatting (it's supposed to, at least), but it would be very difficult to translate.

Thanks,

Ole

cont...@adobeforums.com

unread,
May 21, 2004, 7:17:32 AM5/21/04
to
Hi Ole,

Thanks, I look forward to it.

CP

pbs...@adobeforums.com

unread,
May 24, 2004, 4:05:43 AM5/24/04
to
Hi Contactcp

your examle I mean this code:below export all story is strange for me

myStory.exportFile(myFormat, myFile);

so I can't find it in standard documentation InDesignCS , need I some
additionall dll or something like this ?

Peter

C...@adobeforums.com

unread,
May 24, 2004, 8:42:29 AM5/24/04
to
Hi Peter,

It is on the Indesign CS CD. The script's name is ExportAllStories

I don't really know anything about scripts so I can't really answer but I am hoping Ole will be around soon as he has a solution to the script

CP

Olav_...@adobeforums.com

unread,
May 25, 2004, 7:34:29 PM5/25/04
to
Hi CP--

This version exports all of the stories, then re-imports and links to the stories. Note that RTF cannot capture all of the formatting used in an InDesign story, so some of your formatting might change. If, on the other hand, you use tagged text, the process of translating the text will become much more difficult. You'll also have problems if your stories contain inline frames or tables.

Those disclaimers aside, here's a version that (I think) does what you want:

//ExportAndLinkAllStories.js
//An InDesign CS JavaScript
//
//Exports all stories in an InDesign document in a specified text format and links the exported stories to the document.
//
//For more on InDesign scripting, go to <http://www.adobe.com/products/indesign/scripting.html>
//or visit the InDesign Scripting User to User forum at <http://www.adobeforums.com>
//
if(app.documents.length != 0){
if (app.activeDocument.stories.length != 0){
with(myDialog = app.dialogs.add({name:"ExportAllStories"})){
//Add a dialog column.
myDialogColumn = dialogColumns.add()
with(myDialogColumn){
with(borderPanels.add()){
staticTexts.add({staticLabel:"Export as:"});
with(myExportFormatButtons = radiobuttonGroups.add()){
radiobuttonControls.add({staticLabel:"RTF", checkedState:true});
radiobuttonControls.add({staticLabel:"InDesign Tagged Text"});
}
}
}
myReturn = myDialog.show();
if (myReturn == true){
//Get the values from the dialog box.
myExportFormat = myExportFormatButtons.selectedButton;
myDialog.destroy;
myFolder= Folder.selectDialog ("Choose a Folder");
if((myFolder != null)&&(app.activeDocument.stories.length !=0)){
myExportAllStories(myExportFormat, myFolder);
myLinkAllStories(myFolder);
}
}
myDialog.destroy();
}
}
else{
alert("The document does not contain any text. Please open a document containing text and try again.");
}
}
else{
alert("No documents are open. Please open a document and try again.");
}
//myExportStories function takes care of exporting the stories.
//myExportFormat is a number from 0-1, where 0 = rtf, and 1 = tagged text.
//myFolder is a reference to the folder in which you want to save your files.
function myExportAllStories(myExportFormat, myFolder){
for(myCounter = 0; myCounter < app.activeDocument.stories.length; myCounter++){ myStory = app.activeDocument.stories.item(myCounter); myID = myStory.id; switch(myExportFormat){ case 0: myFormat = ExportFormat.RTF; myExtension = ".rtf" break; case 1: myFormat = ExportFormat.taggedText; myExtension = ".txt" break; } myFileName = "StoryID" + myID + myExtension; myFilePath = myFolder + "/" + myFileName; myFile = new File(myFilePath); myStory.exportFile(myFormat, myFile); } } //Replace and link to the exported files. function myLinkAllStories(myFolder){ app.activeDocument.textPreferences.linkTextFilesWhenImporting = true; for(myCounter = 0; myCounter < app.activeDocument.stories.length; myCounter++){ myStory = app.activeDocument.stories.item(myCounter); myID = myStory.id;

myFileName = "StoryID" + myID + myExtension;

myFilePath = myFolder + "/" + myFileName;

myFile = new File(myFilePath);

myStory.texts.item(0).place(myFile);

}
}

Thanks,

Ole

Olav_...@adobeforums.com

unread,
May 26, 2004, 3:55:14 AM5/26/04
to
Gang--

The @!#$ stupid forum formatting defeats me, as usual. I have tried more than tem times now to get the code in the above example to break correctly, but it refuses to do so (makes me wonder what they think "<pre>" is supposed to mean). Anyway, please break the last "for" loop at the opening brace ("{") and after each semicolon.

Thanks,

Ole

Dave_S...@adobeforums.com

unread,
May 26, 2004, 7:07:33 AM5/26/04
to
Ole,

I think I fixed it. You have to avoid the use of < Either restructure your code, e.g.:

for (i=0; myLim > i; i++) {

or after posting, edit each < replacing with &lt;

Dave

Olav_...@adobeforums.com

unread,
May 26, 2004, 2:16:27 PM5/26/04
to
Dave--

Thanks for the fix! It looks fine now. I generally change the less than sign to the HTML version, but I missed that one (repeatedly!<g>).

Ole

C...@adobeforums.com

unread,
May 26, 2004, 3:22:26 PM5/26/04
to
Hi Ole,

Thanks, I think have it working. You said

"You'll also have problems if your stories contain inline frames or tables. "

Is this the case when also saving to RTF? After running the script. Some of the tables I had have got little red dots in them. Usually in the top left hand corner.

CP

Olav_...@adobeforums.com

unread,
May 26, 2004, 5:29:42 PM5/26/04
to
Hi CP--

The little red dots mean that the cell is too small to hold the text it contains (they're like the overset marker on a text frame).

Yes, it's most likely that this is a result of the formatting changing in the export/import process. Try selecting the table cells in question and re-applying the formatting.

I'm actually somewhat surprised that the tables exported to RTF at all, so, while there are going to be some problems, this is basically good news.

Thanks,

Ole

Richard_...@adobeforums.com

unread,
May 27, 2004, 12:58:48 AM5/27/04
to
RTF handles not only tables but inline images too!

It is very poosible though that the attributes of the table itself (strokes, insets etc.) will change

C...@adobeforums.com

unread,
May 27, 2004, 4:49:08 AM5/27/04
to
The script seems to work very well for exporting and then re-linking. But as this script would be used by a lot of translators let me save you 8 hours of time which is what I spent till 4 o’clock this morning trying to discover why something wasn’t working right.

As most of us translators would use Trados (translation memory tool) to do an analysis of the exported files to get a word count, this will not work. For some reason, you have to open each file and “save as” for it to work.

Everytime I tried to analyse the files without saving as, the word count from Trados was totally wrong (less than 50% of what it should have been). Also, when I tried to translate the exported files from the translation memory it would completely skip text and also strip the paragraph of its style.

I don’t know what happens when you “save as” but this is the only way to make the files stable. Naturally of cause you have to save them back to what they were originally called, after tranlsation, in order for the links to be updated in Indesign.

Another thing I also noticed was that if you open one of the exported files and try to change the style name, you can’t. So there is definitely something strange about the state of the file before you “save as”.

Maybe someone here can explain.

Anyway, thanks Ole for your time as you have saved me plenty of hours of copying and pasting in the future

CP

Richard_...@adobeforums.com

unread,
May 27, 2004, 5:11:35 AM5/27/04
to
I would assume that it has something to do with the fact that RTF is a very complex format and that the flavor of it you get from InDesign is not liked by your other applications.

In what application are you trying to edit the style names, and from what application do you choose "save as"?

Richard_...@adobeforums.com

unread,
May 27, 2004, 5:33:23 AM5/27/04
to
FWIW I have no problems changing style names in Word 2003

C...@adobeforums.com

unread,
May 27, 2004, 5:16:09 AM5/27/04
to
MS Word 2000

Have also tried it on MS Word 2002

CP

Olav_...@adobeforums.com

unread,
May 28, 2004, 1:30:13 PM5/28/04
to
Hi CP--

It's probably that Trados expects the RTF to be RTF exactly as exported by Word. Opening the files in Word and doing a save as is probably the only thing we can do, at this point.

Word can be scripted to do this. I don't have time right now to take it on, but I should be able to get back to it next week.

Thanks,

Ole

0 new messages