Export to rtf format

Dear friends,

I need to export each stories to a separate RTF file.


my code is below,


var stories=app.activeDocument.stories.everyItem().getElements();
for (var i=0; i<stories.length; i++){
   var nFile=new File(nfolder1+"/"+fName.substring(0,fName.length-4)+"rtf");
   stories[i].exportFile(ExportFormat.RTF, nFile);
}

I got an error, but I have now, how to clear this type of errors, please suggest friends, an attached screenshot for your reference below

Screen Shot 2016-03-14 at 3.56.37 PM.png

As the error message says 'nfolder1' is not defined. But even if he had, you end up with a rich text file because you use the same name all the time. You must create a new name for each story, using for example a meter running or the id of each story to tell stories. Something like that will get you started:

var baseName = app.activeDocument.filePath + '/' + app.activeDocument.name.replace (/\.indd$/, '');
var stories=app.activeDocument.stories.everyItem().getElements();
for (var i=0; i

Peter

Tags: InDesign

Similar Questions

Maybe you are looking for