Question
Javascript to delete last 4 bookmarks of every 10 bookmarks
Hi
I have cobbled up some javascript to delete last 4 bookmarks of every 10 bookmarks but it gives me an error saying "TypeError: bm.children[0].children is null
13:Folder-Level:App:Remove last 4 of every 10 bookmarks.js"
Here is the script
if (app.viewerVersion < 10) {
app.addMenuItem({ cName: "RemBM last4every10", cUser: "RemBM last4every10", cParent: "Tools",
cExec: "Removelast4ofevery10BM(this)", cEnable: "event.rc = (event.target != null);"});
} else {
app.addToolButton({ cName: "RemBM last4every10", cLabel: "RemBM last4every10", cTooltext: "RemBM last4every10",
cExec: "Removelast4ofevery10BM(this)", cEnable: "event.rc = (event.target != null);"});
}
/* Remove last 4 of every 10 BM in the document */
function Removelast4ofevery10BM(doc) {
console.clear(); console.show();
var bm = this.bookmarkRoot;
var bmlength = bm.children[0].children[0].children.length;
try {
for (var i = 0; i < bmlength; i++) {
if (i % 10 >= 6) { // Remove the last 4 bookmarks out of every 10
bm.children[0].children[0].children[i].remove();
}
}
}
catch(e) {
app.alert("Processing error: "+e)
}
}
Can someone help please. I am a total novice with javascript. It would be greatly appreciated.
