Skip to main content
Known Participant
Nov 18, 2025 11:06 AM UTC
Question

Sript pour enregistrer tous mes fichiers Indesign en .idml

Bonjour, j'ai ce script, mais il y a une erreur :

/**
* Batch export .indd files to .idml
* Works in Adobe InDesign (via Scripts panel)
*/

(function () {
// Ensure a document isn't left open if something goes wrong
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

// Choose folder
var folder = Folder.selectDialog("Choose folder with .indd files");
if (!folder) {
alert("No folder selected. Script cancelled.");
return;
}

// Get all .indd files
var inddFiles = folder.getFiles("*.indd");
if (!inddFiles || inddFiles.length === 0) {
alert("No .indd files found in the selected folder.");
return;
}

var failedFiles = [];

for (var i = 0; i < inddFiles.length; i++) {
var file = inddFiles[i];

try {
// Open document
var doc = app.open(file);

// Build .idml output path
var idmlPath = file.fullName.replace(/\.indd$/i, ".idml");
var idmlFile = new File(idmlPath);

// Export to IDML
app.activeDocument.exportFile(ExportFormat.INDESIGN_MARKUP, idmlFile);

// Close without saving changes
doc.close(SaveOptions.NO);

} catch (e) {
failedFiles.push(file.fsName + " – " + e);
try {
if (app.documents.length > 0) {
app.activeDocument.close(SaveOptions.NO);
}
} catch (_) {}
}
}

if (failedFiles.length > 0) {
alert(
"Finished with some errors:\n\n" +
failedFiles.join("\n")
);
} else {
alert("All .indd files were successfully exported to .idml.");
}
})();

19 replies

rob day
Community Expert
Community Expert
Nov 18, 2025 5:02 PM UTC
Known Participant
Nov 18, 2025 7:40 PM UTC

Ok thanks, the 1st one is ok (blue surligned), not the 2e one. It's not important.
What i would have like is that it runs on my whole hardrive and do the job for all the files in different folders. May be i'm dreaming ?
Thanks for your help

Translate
Inspiring
Nov 18, 2025 11:26 AM UTC

Bonjour Frédéricd,

Je n'ai pas trouvé des erreurs. Ça marche bien.

Cordialement,

Funtom

 

Translate
Known Participant
Nov 18, 2025 12:11 PM UTC

Merci de votre retour, alors c'est un problème d'emplacement ou de nom du dossier ? ?

Translate
Peter Kahrel
Community Expert
Community Expert
Nov 18, 2025 12:48 PM UTC

You saved the script file as an RTF file. Save it as a plain-text file and the script will run as expected.

Translate