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.");
}
})();
