Copy link to clipboard
Copied
Hello guys,
I have a big problem with the exportFile-method of the Story scripting object. In CS4 the following code results in a file named "icml.icml"
myStory = app.documents[0].stories.itemByID(123);
cacheFile = new File('/Users/username/Desktop/icml.icml');
myStory.exportFile(ExportFormat.INCOPY_MARKUP, cacheFile);
but in CS5 the file name differs in a strange way:
icml-sometext.icml
"sometext" seems to be the first n letters of the story content. Is there any way to disable this feature to have the same file name as in CS4?
Thanks in advance!
Copy link to clipboard
Copied
@Peter: if that's the case, and I have no doubt, but can't test it right now, is there a rule how many additional characters will go into "-sometext"? You could then strip them from the file name by manipulating the string.
Uwe
Copy link to clipboard
Copied
That would be a possible workaround, but my question is, why this behavior has changed in that way since CS4? In my opinion this is a bug, because its not possible any more to get the exact path to an exported file...
Copy link to clipboard
Copied
Hi Peter,
I have tried your code and its seem indesign add extra texts in exported file when same name file already exists on target place.
Try below one becuase its working for me
myStory = app.documents[0].stories.itemByID(197);
cacheFile = new File('/Users/shonky/Desktop/icml.icml');
if(!cacheFile.exists)
{
myStory.exportFile(ExportFormat.INCOPY_MARKUP, cacheFile);
}else
{
alert("File already exists")
}
Shonky
Copy link to clipboard
Copied
This is a good point, thanks. I missed the fact that the file i am exporting already exists because of a previous operation in my code. But for me this behavior is also strange, as i would expect the file to be overwritten like in CS4. But I can make a workaround so the file will not exist before exporting it.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now