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(`
  • ${esc(list[0].path)} (kept)
    ` + list.slice(1).map((b) => esc(b.path)).join('
    ') + '
  • '); } const total = books.reduce((s, b) => s + b.size, 0); $('[data-report]').innerHTML = `

    ${books.length} books, ${fmt(total)} total.

    ${[...byDir].sort((a, b) => b[1].size - a[1].size).map(([d, v]) => ``).join('')}
    ${esc(d)}${v.n} ${fmt(v.size)}

    ${duplicates.length} probable duplicates

    `; $('[data-act=move]').disabled = duplicates.length === 0; } Next: 07 plugin.js (5/5)