[ExtendScript][InDesign]選択したフォルダ内のinddファイルにまとめてスクリプトを実行する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var F = Folder.selectDialog("フォルダを選択してください"); | |
main(F, "filePath", true); | |
function main(F, scptFile, closeFile) { | |
var inddFiles = F.getFiles("*.indd"); | |
var resAry = ["以下のファイルを正しく処理できませんでした"]; | |
var indd, flag; | |
if (!inddFiles) { | |
exit(); | |
} | |
if (!File(scptFile).exist) { | |
alert("ファイル:'" + scptFile + "'が存在しません"); | |
exit(); | |
} | |
for (var i=inddFiles.length-1; i>=0; i--) { | |
flag = false; | |
try { | |
indd = app.open(inddFiles[i]); | |
$.evalFile(scptFile); | |
flag = true; | |
} catch(e) { | |
resAry.push("File: "+inddFiles[i].name+"\r "+e); | |
} finally { | |
if (flag && closeFile) { | |
indd.close(SaveOptions.YES, inddFiles.fullName); | |
} | |
} | |
} | |
if (resAry.length > 1) { | |
alert(resAry.join("\r")); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment