An AI Agent Wrote a Duplicate File Finder in Node. I Ran It on 11 Real Files.
You have a folder full of copies. Same report, three names, three places. So I had an AI agent write a duplicate file finder in Node, and I ran it on a real test folder. Here is what it built and what the run actually fo
You have a folder full of copies. Same report, three names, three places. So I had an AI agent write a duplicate file finder in Node, and I ran it on a real test folder. Here is what it built and what the run actually found.
How it works
Two files with the same content have the same hash. So the tool walks every folder and groups files by hash. But hashing every file is slow, so the agent added a shortcut first: files with a unique size cannot be duplicates, so they never get hashed at all.
The test folder and the run
The test folder has 11 files in three folders. Some are real copies, some only look similar.
- The tool scans 11 files and hashes nine. Two were skipped because their size was unique.
- It finds two groups. The report exists three times under three different names. The photo file exists twice.
- Total wasted space: 17,920 bytes. That is what you would get back by deleting the extra copies.
The tricky cases it got right
This is the part I actually cared about, because "looks like a duplicate" and "is a duplicate" are different things:
- Two notes files with the same name and the same size, but different content. They were hashed and correctly not flagged.
- A file with the same size as the report, but one changed character. Different hash, so not a duplicate.
The size shortcut only skips hashing. It never decides a match on its own.
What I did not test
Huge files. This version reads each file fully into memory, so a multi-gigabyte file would be a problem. A streaming hash would fix that.
One deliberate choice worth copying: the tool never deletes anything. It only prints the groups. That is on purpose, because a delete bug is the worst kind of bug.
The full build and the real run are in the video:
We are building Ship Stack: real experiments on real backends, with the actual numbers, no hand-waving. More of these are on the channel.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.