Skip to main content
Meredith0404
Known Participant
September 20, 2022
Answered

Script that save IDML when saving INDD

  • September 20, 2022
  • 3 replies
  • 1600 views

Is there a script available that will save an IDML each time I save an INDD file? If yes, does that script save over an exisitng IDML for that file (preferred) or does it create a new IDML file with an altered name each time I resave the INDD file?

 

I saw a thread about a script that will save an INDD, IDML and PDF at the same time, but I don't need all of that.

Correct answer Mike Bro

Hello @Meredith0404,

The below script will do what you're asking for...It's a startup script that goes here:

/Applications/Adobe InDesign 2022/Scripts/startup scripts

#targetengine "session"
/////////////////////////////////////////////////////////////////////////////////////////////////////
function saveIDML() {
    if(app.layoutWindows.length == 0) return;
    else if (!app.activeDocument.saved) {
        alert('Sorry, there was a problem and the document was not saved.');
        return;
        }
    var idmlPath =  app.activeDocument.filePath.fsName.replace(/\\/g,'/')+'/'+app.activeDocument.name.replace(/\.indd|\.indt/g,'.idml');
    app.activeDocument.exportFile(ExportFormat.INDESIGN_MARKUP, idmlPath, false);
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////
function saveACopyIDML(e) {
    var idmlPath = File(e.properties.fullName).fsName.toString().replace(/\\/g,'/').replace(/\.indd|\.indt/g,'.idml');
    app.activeDocument.exportFile(ExportFormat.INDESIGN_MARKUP, idmlPath, false);
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Listen for the save event
app.addEventListener('afterSave', saveIDML, false);
app.addEventListener('afterSaveAs', saveIDML, false);
app.addEventListener('afterSaveACopy', saveACopyIDML, false);

Regards,

Mike

3 replies

Mike BroCorrect answer
Legend
September 20, 2022

Hello @Meredith0404,

The below script will do what you're asking for...It's a startup script that goes here:

/Applications/Adobe InDesign 2022/Scripts/startup scripts

#targetengine "session"
/////////////////////////////////////////////////////////////////////////////////////////////////////
function saveIDML() {
    if(app.layoutWindows.length == 0) return;
    else if (!app.activeDocument.saved) {
        alert('Sorry, there was a problem and the document was not saved.');
        return;
        }
    var idmlPath =  app.activeDocument.filePath.fsName.replace(/\\/g,'/')+'/'+app.activeDocument.name.replace(/\.indd|\.indt/g,'.idml');
    app.activeDocument.exportFile(ExportFormat.INDESIGN_MARKUP, idmlPath, false);
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////
function saveACopyIDML(e) {
    var idmlPath = File(e.properties.fullName).fsName.toString().replace(/\\/g,'/').replace(/\.indd|\.indt/g,'.idml');
    app.activeDocument.exportFile(ExportFormat.INDESIGN_MARKUP, idmlPath, false);
    }
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Listen for the save event
app.addEventListener('afterSave', saveIDML, false);
app.addEventListener('afterSaveAs', saveIDML, false);
app.addEventListener('afterSaveACopy', saveACopyIDML, false);

Regards,

Mike

Meredith0404
Known Participant
September 20, 2022

You're all amazing! Thanks so much for everyones' speedy help. Mike, I'll try out your script today/tomorrow (not a design rush need, for once :), but looks like this is exactly what I need.

Robert at ID-Tasker
Legend
September 20, 2022

How about PACKAGE option - but turn off copying fonts and links? 

Community Expert
September 20, 2022

But that would include the PDF I suppose and @Meredith0404 does not want the pdf and also this would require her to do a few more clicks rather than an automatic script. So probably this won't suit her wishes and @Mike Bro has already graciously put togehter a script from scratch so we are good.

-Manan

-Manan
Robert at ID-Tasker
Legend
September 20, 2022

PDF can be turned off as well. 

Community Expert
September 20, 2022

Point us to the script you found and probably it will be quicker to edit it for your needs?

-Manan

-Manan