Script for sorting by categories in XYplorer
Posted: 19 Oct 2026 05:25
Hi, I've been wanting to automatically sort through an old archive of text files (link exports, exported bookmarks, various lists I've accumulated over the years) for a while now, without having to do it all by hand.
Three weeks ago, I finally got around to it. The JS script runs in XYplorer; it scans the name and contents of each file, detects keywords using regex, and moves them directly to the correct subfolder. I tested it on a little over 14,000 files it took all night to run but didn’t crash once and I was honestly pretty happy with the result. The regex gave me a hard time I had false positives everywhere at first, so I called a coworker who’s a bit better at coding this kind of thing than I am, and he helped me clean up the patterns. The real issue wasn’t so much the script as the list of categories itself I didn’t want to just make up my own folder names on a whim; I needed a pre-existing, consistent taxonomy for the detection to make sense... For that, I didn’t reinvent the wheel I just used the structure as a basis. It’s neatly divided into over 100 themes, which served as my reference grid for setting my keyword rules. In the end, the organization is pretty clean there are a few catch-all folders here and there, but nothing too bad. If anyone has tips for further refining detection based on content rather than name, I’d love to hear them.
Three weeks ago, I finally got around to it. The JS script runs in XYplorer; it scans the name and contents of each file, detects keywords using regex, and moves them directly to the correct subfolder. I tested it on a little over 14,000 files it took all night to run but didn’t crash once and I was honestly pretty happy with the result. The regex gave me a hard time I had false positives everywhere at first, so I called a coworker who’s a bit better at coding this kind of thing than I am, and he helped me clean up the patterns. The real issue wasn’t so much the script as the list of categories itself I didn’t want to just make up my own folder names on a whim; I needed a pre-existing, consistent taxonomy for the detection to make sense... For that, I didn’t reinvent the wheel I just used the structure as a basis. It’s neatly divided into over 100 themes, which served as my reference grid for setting my keyword rules. In the end, the organization is pretty clean there are a few catch-all folders here and there, but nothing too bad. If anyone has tips for further refining detection based on content rather than name, I’d love to hear them.