Skip to content

Instantly share code, notes, and snippets.

@Sieboldianus
Last active July 26, 2024 06:15
Show Gist options
  • Save Sieboldianus/dbde439bfd71a6d64fb074ac850b212b to your computer and use it in GitHub Desktop.
Save Sieboldianus/dbde439bfd71a6d64fb074ac850b212b to your computer and use it in GitHub Desktop.
Batch convert all InDesign *.indd files to *.idml files

For backwards compatibility, I wished to batch convert all the *.indd files on my drive to *.idml.

The files are spread over my whole drive.

Here are the steps:

1. Get a list of *.idml files and paths

Use any search tool. Since Windows Search does not work on my side, I am using WSL:

cd /d/
find . -type f -name '*.indd'

Will output something like this..

/d/path1/xyz/x/z/file1.indd
/d/path2/xyz/x/z/file2.indd
/d/path3/xyz/x/z/file3.indd
/d/path4/xyz/x/z/file4.indd

2. Convert into js list

I use notepad++ for this:

2.1 replace /d/ with D:\\
2.2 replace / with \\
2.3 Switch to extended; replace \n with ",\n"

3. Add js code:

var myFileList = [
"D:\\path1\\xyz\\x\\z\\file1.indd",
"D:\\path2\\xyz\\x\\z\\file2.indd",
"D:\\path3\\xyz\\x\\z\\file3.indd",
"D:\\path4\\xyz\\x\\z\\file4.indd"];

for (var i = 0; i < myFileList.length; i++) {

    var myFile = myFileList[i];
    app.linkingPreferences.checkLinksAtOpen = false;
    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
    try {
        app.open(myFile);
        var doc = app.activeDocument;
        var docPath = doc.filePath;
        var docName = doc.name.replace(/\.indd$/i, "");
        var idmlFile = new File(docPath + "/" + docName + ".idml");
        doc.exportFile(ExportFormat.INDESIGN_MARKUP, idmlFile);
        app.documents.everyItem().close(SaveOptions.NO);
    }
    catch(err) {
        alert (myFile);
    }
}

4. Store to indesign script folder

%AppData%\Adobe\InDesign\Version 18.0\en_US\Scripts\Scripts Panel\convert.jsx

(or similar)

5. Run script

  • Open InDesign
  • Go to Window/Tools/Script
  • Select User Scripts/convert.jsx

Summary

The script will:

  • Open all files and store idml files in the same folder
  • Close all original indd files afterwards (without saving)
  • Ignore all missing links or fonts
  • Overwrite existing idml files
  • Not prompt the user under any circumstances, except for issues with opening files

Use with caution. Backup first.

@skingsford
Copy link

This has been very helpful. Thank you.

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