Skip to content

Instantly share code, notes, and snippets.

@arthurattwell
Last active August 22, 2023 19:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurattwell/b4162d0bead352f224dd5266a9d96d5a to your computer and use it in GitHub Desktop.
Save arthurattwell/b4162d0bead352f224dd5266a9d96d5a to your computer and use it in GitHub Desktop.
InDesign Startup Script that saves an IDML copy alongside INDD automatically
// This InDesign Startup Script saves an IDML copy of the INDD file you're saving.
// Save it in your Startup Scripts folder. For how to do that, open the tutorial
// for your version of InDesign here: https://www.adobe.com/devnet/indesign/documentation.html
// and look for the section titled 'Installing scripts'.
// Thanks to fabiantheblind here http://graphicdesign.stackexchange.com/a/71736/67488
// for the original script, which I've adapted to work as a startup script.
// Set a targetengine to make this work
#targetengine "session"
function saveIDML() {
// Exit if no documents are open.
if(app.layoutWindows.length == 0) {
return;
} else {
// Get the current document
var doc = app.activeDocument;
$.writeln('Saving IDML of ' + doc + ' ...');
// Catch errors
if (!doc.saved) {
alert('Sorry, there was a problem and the document was not saved.');
exit();
}
// Create a new .idml file name from the .indd file name
var inddName = doc.name;
var idmlName = inddName.replace("indd", "idml");
// Create the new .idml file next to the .indd file
var theFile = File(File(doc.filePath).fsName + "/" + idmlName);
doc.exportFile(ExportFormat.INDESIGN_MARKUP, theFile, false);
}
}
// Listen for the save event
app.addEventListener('afterSave', saveIDML, false);
@arthurattwell
Copy link
Author

I work with dozens of independent designers on collaborative projects, and those of us with Creative Cloud have to remember to save an IDML copy for those on earlier versions. And we often forget.

So I use this script. It runs when InDesign starts up. Then every time I save an InDesign document, it automatically saves an IDML copy alongside the INDD, in the background.

@MCISTL
Copy link

MCISTL commented Jan 3, 2017

Was just upgraded to CC 2017 and needed a script like this. It's working most of the time but occasionally having issues. I'll document them more as I test it. It launches the ExtendScript Toolkit app when saving in indesign. Has that been the case in the past?

@arthurattwell
Copy link
Author

@MCISTL Sorry, just saw your comment. Are you still having those issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment