IO_PathProcessor
Filter, sort, and clean up a list of file paths with regex
- NewPathList
- FileNameList
- FolderList
If you've ever had a folder of files named img12.png, img(45).png, and AI图片63.png and needed them sorted by the number buried somewhere in each name, you know that's not a job for a plain alphabetical sort. IO_PathProcessor is a batch path cleaner built for exactly that mess - filter, extract a sort key with regex, order the results, and hand back clean parallel lists.
How it works
Feed it path_list, a batch of file paths, and it runs them through a pipeline: filter_suffixes and regex_filter narrow down which paths survive at all, regex_sort_pattern pulls a value out of each surviving filename to sort by, and sort_order (up/down) decides the direction. The README documents the three sort-pattern shapes it's built around, and they cover the practical cases you'll actually hit:
- Number at the start -
^(\d+)- pulls12out of12AI图片.png - Number at the end -
(\d{2})(?=\.\w+$)- pulls63out ofAI图片63.png - Number in parentheses -
\((\d+)\)- pulls45out of图片(45).png
remove_file_suffix (default true) strips extensions from the output filenames, and path_duplication_count lets you repeat each surviving path N times in the output - handy if downstream you need, say, three passes per source image and don't want to build that repetition by hand.
Inputs and outputs
The fields you'll actually touch: path_list (the input batch), regex_filter (keep only matching paths), regex_sort_pattern (extract the sort key), sort_order, and path_duplication_count. filter_suffixes and remove_file_suffix round out the extension handling.
Three outputs, all STRING lists: NewPathList (the filtered, sorted paths), FileNameList (just the filenames), and FolderList (just the containing folders) - pick whichever shape the next node in your graph wants.
How to install it
ComfyUI Manager → search ComfyUI-Apt_Preset, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
then run install.bat for dependencies (Windows-only - on Linux/macOS run its pip install lines by hand) and restart ComfyUI.
Common issues & troubleshooting
Don't hand-write regex if you don't have to. This pack ships a companion node, IO_RegexPreset, that builds a working pattern from a plain-language preset (contains keyword, starts with, matches digits, and so on) and outputs it as a STRING - pipe that straight into regex_filter or regex_sort_pattern instead of debugging your own regex against real filenames.
A sort pattern that doesn't match anything just doesn't sort. If regex_sort_pattern doesn't find a match in a given filename, that path has no sort key to work with - test your pattern against a couple of real filenames from the batch (or use IO_RegexPreset's own preview_test_text field to check it) before trusting the output order.
IMPORT FAILED on startup. This pack has at least one reported import failure in the wild on a stock install, generally traced to skipping the install.bat dependency step - easy to miss off Windows, where you have to run its pip install lines yourself. Check the console for the specific missing package first.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| path_list | STRING | — | |
| remove_file_suffix | BOOLEAN | true | — |
| filter_suffixes | STRING | — | |
| regex_filter | STRING | — | |
| regex_sort_pattern | STRING | — | |
| sort_order | COMBO | up | 2 options: up, down |
| path_duplication_count | INT | 11–100 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| NewPathList | STRING | — |
| FileNameList | STRING | — |
| FolderList | STRING | — |