Highlighted

export every open file to idml

Explorer ,
Jun 11, 2020

Copy link to clipboard

Copied

I'm trying to export every open InDesign file to idml in the same folder.

(I'm trying javascript and Visual Studio Code for the first time.)

 

main();
function main(){

    var i;
    for (i = 0; i < app.documents.length - 1; i++) {
        fileName = app.documents.item(i).filePath + "/" + app.documents.item(i).name.split('.').slice(0, -1).join('.') + "\.idml";
        app.documents.item(i).exportFile(ExportFormat.INDESIGN_MARKUP, fileName);
    } 

}

 

But, I get the following error.

Runtime Error: Error Code# 48: Folder ""/c/temp/test.idml"" not found.

 

What do I need to do here?

I also need this to work if the path is to a folder on the Desktop (e.g., ""~/Desktop/temp/test.idml"").

 

Thanks.

Hello Tak Osato

The code below with some slight modifactions works for me.

 

main();
function main(){
  
var i;
for (i = 0; i < app.documents.length; i++) {
var fileName = app.documents.item(i).name.replace(/.indd/, ""); 
var myIDML = new File(File(app.documents.item(i).filePath).fsName + "/" + fileName + ".idml");
app.documents.item(i).exportFile(ExportFormat.INDESIGN_MARKUP, myIDML);
   } 

}

 

 

Regards,

Mike

TOPICS
Scripting

Views

304

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

export every open file to idml

Explorer ,
Jun 11, 2020

Copy link to clipboard

Copied

I'm trying to export every open InDesign file to idml in the same folder.

(I'm trying javascript and Visual Studio Code for the first time.)

 

main();
function main(){

    var i;
    for (i = 0; i < app.documents.length - 1; i++) {
        fileName = app.documents.item(i).filePath + "/" + app.documents.item(i).name.split('.').slice(0, -1).join('.') + "\.idml";
        app.documents.item(i).exportFile(ExportFormat.INDESIGN_MARKUP, fileName);
    } 

}

 

But, I get the following error.

Runtime Error: Error Code# 48: Folder ""/c/temp/test.idml"" not found.

 

What do I need to do here?

I also need this to work if the path is to a folder on the Desktop (e.g., ""~/Desktop/temp/test.idml"").

 

Thanks.

Hello Tak Osato

The code below with some slight modifactions works for me.

 

main();
function main(){
  
var i;
for (i = 0; i < app.documents.length; i++) {
var fileName = app.documents.item(i).name.replace(/.indd/, ""); 
var myIDML = new File(File(app.documents.item(i).filePath).fsName + "/" + fileName + ".idml");
app.documents.item(i).exportFile(ExportFormat.INDESIGN_MARKUP, myIDML);
   } 

}

 

 

Regards,

Mike

TOPICS
Scripting

Views

305

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 11, 2020 0
Engaged ,
Jun 11, 2020

Copy link to clipboard

Copied

Hello Tak Osato

The code below with some slight modifactions works for me.

 

main();
function main(){
  
var i;
for (i = 0; i < app.documents.length; i++) {
var fileName = app.documents.item(i).name.replace(/.indd/, ""); 
var myIDML = new File(File(app.documents.item(i).filePath).fsName + "/" + fileName + ".idml");
app.documents.item(i).exportFile(ExportFormat.INDESIGN_MARKUP, myIDML);
   } 

}

 

 

Regards,

Mike

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 11, 2020 1
Explorer ,
Jun 11, 2020

Copy link to clipboard

Copied

Hi Mike,

 

Thanks! It worked.

 

If you don't mind me asking, what's the deal with

 

File(File(app.documents.item(i).filePath).fsName

 

When I put this in my "Watch" list, the value seems to be the same as my original fileName variable.

 

Tak

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 11, 2020 0
Adobe Community Professional ,
Jun 11, 2020

Copy link to clipboard

Copied

Have the open docs been saved? A file needs to have been saved for doc.filepath to return a folder.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 11, 2020 0
Explorer ,
Jun 11, 2020

Copy link to clipboard

Copied

Hi Rob,

 

Yes, the open docs have been saved. Thanks for the reminder, though.

 

Tak

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 11, 2020 0
Adobe Community Professional ,
Jun 12, 2020

Copy link to clipboard

Copied

Hi Mike,

I would refine the RegExp used from:

replace(/.indd/, "");

to:

replace(/\.indd$/i,"");

 

Hope, the reason is obvious to you.

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 12, 2020 0