Nodes/honda-nodes/πŸ“‚ Move File
ComfyUI Node

πŸ“‚ Move File

File cleanup as a step in the graph, not a chore afterwards

By AvarayΒ·Created 14 days agoΒ·Updated 12 days agoΒ· 0
πŸ“‚ Move File
    • Destination Path
    β—„source_pathβ–Ί
    β—„destination_pathβ–Ί

    Here's the boring truth about generating a lot of images: the hard part isn't the sampler, it's that everything lands in one flat output/ folder in filename order and you spend your evenings sorting it. Move File lets the workflow do the sorting while it runs - after saving, take the path Save Image just returned and put the file wherever it actually belongs.

    How it works

    It's shutil.move with a little politeness in front: the source and destination are stripped of whitespace, the destination's parent directory is created if it doesn't exist (os.makedirs(..., exist_ok=True)), and then the file is moved. Because the parent gets made for you, you can hand it a destination inside a folder that won't exist until the run - .../output/sdxl/portraits/run_07/ - and it works on the first attempt.

    "Move" is shutil.move, which means it's a rename when source and destination are on the same filesystem and a copy-then-delete when they're not. Same disk: instant. Across disks or to a network share: proportional to file size, and it will block the graph while it copies.

    The behaviour that matters most is what happens when things go wrong, which is: almost nothing. The whole body is guarded by if source_path and destination_path and os.path.exists(source_path) - if the source doesn't exist, the node quietly does nothing and still returns the destination path you gave it. No exception, no warning, no red box. A typo in a path gets you a clean green run and a file that never moved.

    The inputs and outputs that matter

    Source Path - absolute path to the file, usually wired straight from Save Image's PNG Path or from Load Image's Path output. Destination Path - absolute path to where it should end up, including the filename. It's a full path, not a folder: point it at a directory and you'll get a file named after the directory, or an error depending on the platform.

    One output: Destination Path, echoing the destination you supplied. That's the point of it - chain Move File into Rename File, or into another Move File, or into Print to Console when you're debugging a batch. Common shape for a sorting pipeline:

    Save Image PNG Path β†’ Move File (into output/portraits/) β†’ Rename File (stamp a better name) β†’ the final path into your notes/log.

    For the destination, don't hand-type paths: Path Join builds one from segments and handles separators per-OS, which is the difference between a workflow that runs on your Windows box and on the Linux box next to it.

    How to install it

    In Avaray/honda-nodes - ComfyUI Manager β†’ Node Pack β†’ search Honda Nodes β†’ Install β†’ restart. Manual:

    cd ComfyUI/custom_nodes
    git clone --depth 1 https://github.com/Avaray/honda-nodes.git
    cd honda-nodes
    python install.py
    

    This node is pure stdlib and needs nothing from install.py, but the script is what fetches the jq and ime binaries for the rest of the pack - run it once and forget it. No pip packages, no models.

    Common issues

    Nothing moved and the run was green. The silent-no-op guard. 99% of the time it's one of three things: the source path has a trailing space from a wired string, the source genuinely doesn't exist yet (Move File can be scheduled before Save Image in the execution order it inferred - check what's actually wired to what), or you passed a relative path and it resolved against ComfyUI's working directory rather than the folder you were looking at.

    It failed on Windows with a file-already-exists error. shutil.move ends up at os.rename, and the platforms disagree about overwrites: on Linux and macOS an existing destination file is replaced silently, on Windows it raises. If a batch can produce the same destination twice, make the destination unique (a counter from Save Image's filename, a Path Join with a run name) rather than relying on overwrite semantics.

    It's slow on a big batch. You're crossing filesystems - copying instead of renaming. Put the destination on the same drive as output/ if you can.

    Folders full of half-moved files after a crash. Inherent to file operations in a graph: if ComfyUI dies mid-copy, you get a partial file at the destination. Not much the node can do about it; keep moves at the end of the chain, after the pixels are safely written.

    The general warning for this whole node group: there's no sandbox. Any path the ComfyUI process can reach, these nodes will move. Be careful with a wired destination and a wide eye on the absolute path before you hit Run the first time.

    Category⚑️ Honda Nodes/πŸ“‚ File System

    Inputs (2)

    NameTypeDefaultDescription
    source_pathSTRINGβ€”
    destination_pathSTRINGβ€”

    Outputs (1)

    NameTypeDescription
    Destination PathSTRINGβ€”