CopyAndRenameFiles
CopyAndRenameFiles – ComfyUI Node
- save_directory
What it is
CopyAndRenameFiles is a small filesystem-batching utility: point it at a source directory, and it copies every file in there to a destination directory, renaming them as it goes - sequential numbers by default. It's the kind of node that only makes sense once you're using ComfyUI for something more automated than clicking Queue Prompt one image at a time: batch dataset prep, sorting outputs from a big run into a clean numbered sequence for a training set, or staging files for whatever pipeline picks them up next.
There's a second, less obvious mode buried in the README's description: if you leave the destination directory empty, the node renames the files in place in the source directory instead of copying them anywhere. That's a meaningfully different operation - one moves and renumbers files, the other copies and renumbers them - so it's worth being deliberate about which one you actually want before you run it.
Inputs and outputs
Four inputs, all with sensible defaults except the source:
directory(STRING, required) - the source folder to read files from.save_directory(STRING, default empty) - where to copy the renamed files. Leave it blank and the node renames originals in place instead of copying.prefix(STRING, default empty) - prepended to each output filename.name_to_num(BOOLEAN, defaulttrue) - when on, files get renamed to sequential numbers; this is presumably what governs the naming scheme beyond just the prefix.
One output: save_directory (STRING) - echoes back the directory the files ended up in, which is genuinely useful, because it means you can wire this straight into a downstream node that expects a directory path (this pack's own LoadLocalFilePath or LoadImageFromLocalPath, for instance) without hardcoding the path twice.
How it works
Mechanically it's a filesystem copy-and-rename loop running server-side inside the executor. That matters for one reason: the paths you give it are paths on the machine running ComfyUI, not paths on whatever browser or client you're driving the API from. If you're running ComfyUI locally that's a non-issue. If you're driving a remote or hosted ComfyUI instance through the API, directory needs to point somewhere that actually exists on that server's filesystem - you can't point it at a folder on your own laptop.
Installing it
Bundled in comfyui-easyapi-nodes. Through ComfyUI Manager: search "comfyui-easyapi-nodes", install, restart ComfyUI. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt
Upgrade later with git pull in that folder. This node itself is plain filesystem operations with no exotic dependency, but running the requirements install keeps the rest of the pack (some of which does need extra packages) working too.
Common issues
"Nothing got copied, and no error either." Check that directory is an absolute path that actually exists on the ComfyUI host, and that the ComfyUI process has read permission on it and write permission on save_directory. A quiet no-op is the classic symptom of a path that's valid syntax but doesn't resolve to anything real from the server's point of view - a very easy mistake when you're used to browsing files locally and forget the node runs server-side.
"Files got renamed but I wanted copies, and now my originals are gone / renamed." That's the save_directory-empty behavior described in the README - leaving that field blank renames in place rather than copying. If you want the source untouched, make sure save_directory is actually set to somewhere else.
"allow_create_dir_when_save" - do I need to worry about a missing destination folder? The pack's changelog mentions a config option controlling whether directories get auto-created on save (relevant to this node and the pack's file-saving nodes generally). If copies are failing specifically because the target folder doesn't exist yet, check the EasyApi settings for that toggle before assuming the node is broken - it may just be refusing to create a directory it wasn't told it's allowed to create.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| directory | STRING | 源目录 | |
| save_directory | STRING | 目标目录,为空时重命名原文件 | |
| prefix | STRING | 新文件名前缀 | |
| name_to_num | BOOLEAN | true | 后缀是否使用在对应目录的序号 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| save_directory | STRING | — |