Copy link to clipboard
Copied
I have been using a script to export all text from a document and haven't had any issues with it.
Then today I went to use it and I'm am having this message pop up.
JavaScript Error!
Error Number: 48
Error String: Cannot find the folder "/Volumes/Private/var/folders/d1/7nsrmmm94kb872qbgvv5tl9c0000gn/T/TemporaryItems/tempTextFile.txt".
Engine: main
File: /Applications/Adobe InDesign CC 2017/Scripts/Scripts Panel/Samples/JavaScript/ExportAllText CS3.jsx
Line: 55
Source: myStory.exportfile(ExportFormat.taggedText,myTempFile);
Here is the script I have been using.
Any suggestions?
if(app.documents.length != 0){
if(app.documents.item(0).stories.length != 0){
myGetFileName(app.documents.item(0).name);
}
}
//========================= FUNCTIONS ===========================
function myGetFileName(myDocumentName){
var myFilePath = File.saveDialog("Save Exported File As:");
if(myFilePath != null){
myDisplayDialog(myDocumentName, myFilePath);
}
}
//--------------------------------------------------------------------------------------------------------------
function myDisplayDialog(myDocumentName, myFilePath){
//Need to get export format, story separator.
var myExportFormats = ["Text Only", "Tagged Text", "RTF"];
var myDialog = app.dialogs.add({name:"ExportAllStories"});
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
var myExportFormatDropdown = dropdowns.add({stringList:myExportFormats, selectedIndex:0});
}
}
with(dialogRows.add()){
var myAddSeparatorCheckbox = checkboxControls.add({staticLabel:"Add separator line", checkedState:true});
}
}
var myResult = myDialog.show();
if(myResult == true){
var myExportFormat = myExportFormats[myExportFormatDropdown.selectedIndex];
var myAddSeparator = myAddSeparatorCheckbox.checkedState;
myDialog.destroy();
myExportAllText(myDocumentName, myFilePath, myExportFormat, myAddSeparator);
}
else{
myDialog.destroy();
}
}
//--------------------------------------------------------------------------------------------------------------
function myExportAllText(myDocumentName, myFilePath, myExportFormat, myAddSeparator){
var myPage, myStory;
var myExportedStories = [];
var myTempFolder = Folder.temp;
var myTempFile = File(myTempFolder + "/tempTextFile.txt");
var myNewDocument = app.documents.add();
var myDocument = app.documents.item(myDocumentName);
var myTextFrame = myNewDocument.pages.item(0).textFrames.add({geometricBounds:myGetBounds(myNewDocument, myNewDocument.pages.item(0))});
var myNewStory = myTextFrame.parentStory;
for (var i = 0; i < myDocument.pages.length; i++) {
myPage = myDocument.pages.item(i);
for (var t = 0; t < myPage.textFrames.length; t++){
myStory = myPage.textFrames
if (!IsInArray(myStory.id, myExportedStories)) {
//Export the story as tagged text.
myStory.exportFile(ExportFormat.taggedText, myTempFile);
myExportedStories.push(myStory.id);
//Import (place) the file at the end of the temporary story.
myNewStory.insertionPoints.item(-1).place(myTempFile);
//If the imported text did not end with a return, enter a return
//to keep the stories from running together.
if(i != myDocument.stories.length -1){
if(myNewStory.characters.item(-1).contents != "\r"){
myNewStory.insertionPoints.item(-1).contents = "\r";
}
if(myAddSeparator == true){
myNewStory.insertionPoints.item(-1).contents = "----------------------------------------\r";
}
}
} // if not exported
} // for text frames
} // for pages
switch(myExportFormat){
case "Text Only":
myFormat = ExportFormat.textType;
myExtension = ".txt"
break;
case "RTF":
myFormat = ExportFormat.RTF;
myExtension = ".rtf"
break;
case "Tagged Text":
myFormat = ExportFormat.taggedText;
myExtension = ".txt"
break;
}
myNewStory.exportFile(myFormat, File(myFilePath));
myNewDocument.close(SaveOptions.no);
myTempFile.remove();
}
//--------------------------------------------------------------------------------------------------------------
function myGetBounds(myDocument, myPage){
var myPageWidth = myDocument.documentPreferences.pageWidth;
var myPageHeight = myDocument.documentPreferences.pageHeight
if(myPage.side == PageSideOptions.leftHand){
var myX2 = myPage.marginPreferences.left;
var myX1 = myPage.marginPreferences.right;
}
else{
var myX1 = myPage.marginPreferences.left;
var myX2 = myPage.marginPreferences.right;
}
var myY1 = myPage.marginPreferences.top;
var myX2 = myPageWidth - myX2;
var myY2 = myPageHeight - myPage.marginPreferences.bottom;
return [myY1, myX1, myY2, myX2];
}
//--------------------------------------------------------------------------------------------------------------
function IsInArray(myString, myArray) {
for (x in myArray) {
if (myString == myArray
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------------------
[EDIT – moved to In Design Scripting – moderator]
Copy link to clipboard
Copied
It is working fine in my end. I tested in CS6 and CC2017
Copy link to clipboard
Copied
Hi All,
We are facing similar kind issue today. Before today it was working fine. But today, it is start throwing below kind error.
JavaScript Error!
Error Number: 48
Error String: Cannot find the folder "/test/1567.indd".
Please advise ASAP.
Copy link to clipboard
Copied
Hello Deepak,
We are gonna more information on the issue, for starters what is the script that you are using. We are mere mortals not wizards to tell you what might be wrong in your code. Also please don't revive an old thread, as you won't get many eyeballs on your query this way. I suggest you open up a new question with more details like the script you are having trouble with and me and other members would be more than willing to help you out.
-Manan
Copy link to clipboard
Copied
Thanks Manan and appreciate your quick response over this.
Currently the issue has been resolved by our network team. There were some problems in resolving DNS entries.
Once again thanks for all your help.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more