Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var doc = app.activeDocument;
var pst = doc.allParagraphStyles;
pst.splice(0, 2);
var pstNameList = getNames(pst);
var result = {}; //エラー結果を入れる配列
for (var i=0, ilen=pstNameList.length; i<ilen; i++) {
for (var k=0, klen=pstNameList.length; k<klen; k++) {
if (i === k) {
continue;
}
if (pstNameList[i] === pstNameList[k]) {
result[pstNameList[i]] = ""; //空の連想配列
}
}
}
if (result.length !== 0) {
alert("以下の段落スタイル名が重複しています\r" + getKeys(result).join("\r"));
} else {
alert("直復した段落スタイル名は見つかりませんでした");
}
function getNames(objAry) {
var result = [];
for (var i=0, len=objAry.length; i<len; i++) {
if (objAry[i].hasOwnProperty("name")) {
result.push(objAry[i].name);
}
}
return result;
};
function getKeys(obj) {
var result = [];
for (var key in obj) {
result.push(key);
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment