PD_rename_V2
Stripping a keyword out of every image filename — in place or into a new folder
- result_message
- renamed_count
A tagger left _R on every image filename, or your downloads all have _copy glued in, and you want them gone across a whole folder. That's this node: give it a folder and a keyword, and it removes that substring from every matching image filename - either in place, or by copying the cleaned files into a new folder while keeping the originals. Two inputs, two outputs, no surprises.
It's the "remove keyword" sibling of PD_Name_ReplaceWordOrder in the same pack (which moves a keyword instead of deleting it) and PD_number_star (which numbers). Together they cover most of the "my filenames are a mess" cases.
How it works
It scans the folder (non-recursive) for image files - jpg, jpeg, png, bmp, tiff, webp - whose name contains keyword_to_remove, and builds the new name by removing that substring. A few guardrails from the source:
- If the result would be an empty stem or just an extension, the file is skipped.
- If the destination filename already exists, the file is skipped, not overwritten.
- With
output_pathempty, it renames the originals in place. Withoutput_pathset, it copies the cleaned files to that folder (creating it if needed) and leaves the originals untouched - which is the safe mode and the reason the V2 in the name exists. - A file whose name doesn't contain the keyword is ignored entirely.
The result comes back as two outputs: result_message (a readable per-file report) and renamed_count (an INT, handy for wiring into a status check or a count-display node).
The inputs that matter
folder_path- required; validated, with errors returned as the result message.keyword_to_remove- the substring to strip. Empty input is rejected.output_path- optional. Empty = rename in place; set = copy into this folder.
Installing it
Part of Comfyui_PDuse by 7BEII. ComfyUI Manager (search "PDuse") or:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse.git
cd Comfyui_PDuse
pip install -r requirements.txt
Restart. No model downloads; pack deps are numpy, Pillow, scipy, opencv-python, torchvision. Docs are Chinese-first.
Where people get burned
The keyword is a plain substring, not a word-boundary match - removing R will hit R anywhere in the name, including inside Rear.jpg or car_R2.png. The pack's other renamer uses \b boundaries, so if you need word-safe deletion that's the one. Second, it only touches the image extensions listed; .txt captions in the same folder are left alone. Third, in-place mode has no undo - when you care about the originals, always set output_path. The renamed-count output also only counts files actually moved; skipped collisions land in the message, not the count.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| folder_path | STRING | — | |
| keyword_to_remove | STRING | — | |
| output_path | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| result_message | STRING | — |
| renamed_count | INT | — |