Examples > file-tool PLUGIN.JS (4/5) function report(books) { const byDir = new Map(); for (const b of books) { const d = byDir.get(b.dir) || { n: 0, size: 0 }; d.n++; d.size += b.size; byDir.set(b.dir, d); } const groups = new Map(); for (const b of books) (groups.get(key(b.name)) || groups.set(key(b.name), []).get(key(b.name))).push(b); duplicates = []; const dupRows = []; for (const list of groups.values()) { if (list.length < 2) continue; list.sort((a, b) => b.size - a.size); // keep the biggest copy for (const extra of list.slice(1)) duplicates.push(extra.path); dupRows.push(`
${books.length} books, ${fmt(total)} total.
| ${esc(d)} | ${v.n} | ${fmt(v.size)} |
${duplicates.length} probable duplicates