AIファイルの入ってるフォルダーを選択;そのフォルダー内全ての**.ai**ファイル(子フォルダー内のも)全てX-1aPDFに保存(同じ階層に)
AI2X-1aPDF.jsx
#target "Illustrator"
var folderObj = Folder.selectDialog("Select a folder");
var all = [];
if (folderObj) {
getAI(folderObj);
var i = all.length;
if (i) {
while (i--) {
var m = all[i].length;
while (m--) {
ai2pdf(all[i][m]);
}
}
}
alert("Completed");
} else {
alert("Please select a folder");
}
//////////////////////////////////////////////////////////
function getAI(folderObj) {
var aiList = folderObj.getFiles("*.ai");
if (aiList) all.push(aiList);
var fileList = folderObj.getFiles();
var L = fileList.length;
while (L--) {
if (fileList[L].constructor.name === "Folder") getAI(new Folder(fileList[L].fullName));
}
}
//////////////////////////////////////////////////////////
function ai2pdf(aiPath) {
var fileObj = new File(aiPath);
var doc = app.open(fileObj);
if (fileObj.open()) {
var fname = fileObj.name.slice(0, -3);
options = new PDFSaveOptions();
options.pDFPreset = "[PDF/X-1a:2001 (日本)]";
options.preserveEditability = false;
savefile = new File(fileObj.path + "/" + fname + ".pdf");
doc.saveAs(savefile, options);
}
doc.close(SaveOptions.DONOTSAVECHANGES);
}