1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

全てのAIファイルをX-1a PDFに保存(子フォルダー内のAIファイルも)

Posted at

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);
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?