I need to reduce my duplicate tracks stored on my hard drive which are all referenced in…
- User
I need to reduce my duplicate tracks stored on my hard drive which are all referenced in my Traktor NML collection. Scan an input Traktor NML collection reading all files in the collection, produce a list of any tracks that have the same artist & title. Group the duplicates by letter for expanding and dealing with. When clicking on a potential duplicate, show all tracks found with Artist, Title, Genre, time, filepath and playlists it is in. I want to then modify the collection NML later to put the deemed keep tracks into playlist whilst removing the others from disk, are you comfortable editting the NML file safely?
Assistant
I'll build a Traktor NML duplicate finder that runs entirely in your browser (no upload to any server). Let me plan and yes—I'll address the NML safety question upfront in the UI and in code.
Approach:
- Upload NML → parse as XML in-browser with DOMParser
- Index all
<ENTRY>tracks + build a playlist membership map from<PLAYLISTS> - Find duplicates by normalized
artist|titlekey - Group alphabetically (A–Z, 0–9, other) with collapsible sections
- Click a group → expand tracks showing Artist, Title, Genre, Time, Filepath, Playlists
- Mark tracks as Keep or Delete
- Export: (a) a modified NML with a new "_KEEP_DUPLICATES" playlist appended (originals preserved), plus (b) a delete list (.txt / .sh / .bat) since browsers can't delete files on disk
NML safety strategy: parse → mutate only the
<PLAYLISTS>tree (add a new PLAYLIST NODE), never modify existing ENTRY/LOCATION/other playlists → serialize back preserving structure. Always keep the original file as backup (I remind users of this in the UI).Let me look at the project structure first.
Now let me create the NML parser utility:
Now the main App component:
Now let's build to verify:
Build succeeded. Here's what I made and answers to your questions:
The app
A single-page, browser-only React tool. Nothing gets uploaded anywhere — your
collection.nmlis parsed withDOMParserright in your tab.Workflow:
- Load your
collection.nml(typically~/Documents/Native Instruments/Traktor X.Y.Z/collection.nml). - Duplicates are detected by normalized
artist|title(case + whitespace + smart-quote tolerant, but the stored strings themselves are never altered). - Grouped by first letter of artist (A–Z, plus
0-9and#buckets). Click a letter to expand, click a group to expand its copies. - Each track card shows Artist, Title, Genre, Time, Bitrate, Size, full file path, and every playlist it appears in (built from the
<PLAYLISTS>tree via eachPRIMARYKEY KEY). - Mark each copy Keep or Delete. There's an "Auto-mark: keep largest file per group" helper as a starting point.
- Filter by text, or show only undecided groups so you can grind through them.
- Live stats: dup groups, extra copies, marked-for-delete count, and approximate GB that will be freed.
Export
- Modified NML — appends two new playlists to
$ROOT:_KEEP_DUPLICATESand_DUPLICATES_TO_DELETE. Nothing existing is touched. - Delete list — the tracks you marked "delete" as
.txt,.sh(withDRY=1preview),.bat, or.ps1— because a browser can't touch your disk, but a small shell/batch script can, after you review it.
Am I comfortable editing the NML safely? — Yes, with these guardrails
The NML is just XML, so it edits cleanly if you're careful. My approach:
- Parse → mutate → re-serialize with
DOMParser/XMLSerializer. That preserves every attribute Traktor cares about (cue points, tempo, loudness, musical key, colour, comments, import date, etc.). - Additive changes only. I never remove or rewrite existing
<ENTRY>,<LOCATION>, or existing playlist nodes. I only append two new<NODE TYPE="PLAYLIST">underPLAYLISTS/NODE[NAME="$ROOT"]/SUBNODESand bump itsCOUNT. - Correct
PRIMARYKEY KEYformat — reconstructed asVOLUME/:dir/:fileexactly as Traktor uses elsewhere in the file, so Traktor will resolve the playlist entries back to the right collection tracks. - New UUID per playlist so it doesn't clash with existing ones.
- Clone the DOM before mutating so re-exporting doesn't compound edits.
- The UI includes a safety checklist: back up your original NML, close Traktor before swapping the file (Traktor rewrites the NML on quit and will happily overwrite your changes), and delete files before re-opening Traktor so its "Check consistency" flow can clean up the orphaned entries.
If you'd like, once you've had a first pass I can extend it to also remove the marked-delete entries from
<COLLECTION>and scrub theirPRIMARYKEYreferences from every existing playlist — I left that off by default because deleting from disk + letting Traktor's consistency check remove the orphans is safer than editing the collection body directly.Files built:
index.html,src/utils/nml.ts,src/App.tsx
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.