Skip to main content
Meredith0404
Known Participant
Sep 20, 2022 4:01 PM UTC
Answered

Script that save IDML when saving INDD

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.

Mike BroCorrect answer
Legend
Sep 20, 2022 4:20 PM UTC

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

10 replies

Mike BroCorrect answer
Legend
Sep 20, 2022 4:20 PM UTC

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

Translate
Meredith0404
Known Participant
Sep 20, 2022 4:41 PM UTC

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.

Translate
Robert at ID-Tasker
Legend
Sep 20, 2022 4:13 PM UTC

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

Translate
Community Expert
Sep 20, 2022 4:36 PM UTC

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

Translate
-Manan
Robert at ID-Tasker
Legend
Sep 20, 2022 8:40 PM UTC

PDF can be turned off as well. 

Translate
Community Expert
Sep 20, 2022 4:10 PM UTC

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

-Manan

Translate
-Manan