Skip to content

Instantly share code, notes, and snippets.

@milligramme
Last active March 24, 2018 15:43
Show Gist options
  • Select an option

  • Save milligramme/6847ec5aec5435ea0110 to your computer and use it in GitHub Desktop.

Select an option

Save milligramme/6847ec5aec5435ea0110 to your computer and use it in GitHub Desktop.
export idml from indd and then convert idml to indd

InDesign 7.5 to 7.0 downconverting

exec export_idml.jsx

it will export idmls into idml folder

exec idml_to_indd_with_name.jsx

#target "InDesign-7.5"
// indd7.5 => idml
(function () {
var export_to_idml = function (doc) {
try {
var idml_path = doc.fullName.parent + "/idml/" + doc.name.replace(/\.indd/,".idml");
doc.exportFile(ExportFormat.INDESIGN_MARKUP, new File(idml_path));
}
catch(x_x){
// ignore indd7 or early?
$.writeln(x_x);
}
}
var ind_folder = Folder.selectDialog('indd?');
if (ind_folder !== null) {
var indds = ind_folder.getFiles(/\.indd/);
if (indds.length > 0 && !File(ind_folder + "/idml").exists) {
Folder(ind_folder + "/idml").create();
}
for (var i=0, len=indds.length; i < len ; i++) {
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var doc = app.open(indds[i], false);
export_to_idml(doc);
doc.close(SaveOptions.NO);
};
}
alert("to idml.");
})();
#target "InDesign-7.0"
// idml to indd with document name
(function () {
var idml_folder = Folder.selectDialog('idml!!');
if (idml_folder !== null) {
var idmls = idml_folder.getFiles(/\.idml/);
for (var i=0, len=idmls.length; i < len ; i++) {
var idml = idmls[i];
var indd_path = idml.toString().replace(/\.idml$/, ".indd");
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
var doc = app.open(File(idml), false);
doc.save(new File(indd_path));
doc.close(SaveOptions.YES);
};
}
alert('to indd');
})();
@yousiph
Copy link

yousiph commented Mar 24, 2018

hd-creative-pictures

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