Nodes/comfyui-huyl2-nodes/Clear Folder (rm -r *)
ComfyUI Node

Clear Folder (rm -r *)

Wipe a directory clean from inside your graph

By huyl3-cpu·Created 9 months ago·Updated 4 months ago· 1
Clear Folder (rm -r *)
    • result
    folder_path

    The display name isn't marketing copy, it's a literal description: this node recursively deletes everything inside a folder. No confirmation, no dry run - point it at a path and it's gone.

    What it's for

    Automated video and file-processing pipelines generate a lot of scratch data - cut segments, intermediate frame dumps, temp files - and if you're running loops (this pack ships SimpleForLoopStart/SimpleForLoopEnd for exactly that), that scratch data piles up fast. Colab environments in particular have limited, ephemeral disk, which is the world this pack's README is written for. This node exists to clear a working directory between passes so you don't run out of space mid-job.

    How it works

    You give it folder_path, it empties it. The schema marks this node as an output node (is_output_node: true), which in ComfyUI terms means it behaves like SaveImage - it's treated as a terminal step in the graph and will actually execute during a queue run even if nothing downstream reads its output. In other words: wire it in, and it will run, whether or not anything is listening to result.

    Inputs and outputs

    • folder_path (STRING, required) - the directory to empty.
    • Output: result (STRING) - presumably a status message confirming what happened.

    That's the entire interface. No pattern filter, no whitelist, no confirmation step.

    Installing it

    There's no requirements.txt or model download in the README - this is pure Python filesystem code. Try ComfyUI Manager first (search the repo name), but given how small and personal this pack is, don't be surprised if it isn't indexed. The reliable path:

    cd ComfyUI/custom_nodes
    git clone https://github.com/huyl3-cpu/comfyui-sortlist.git
    

    Restart ComfyUI afterward.

    Common issues and troubleshooting

    This is the single most dangerous node in the whole pack, and it's worth treating it that way. It's a recursive delete with no confirmation, and because it's an output node it runs automatically whenever the queue reaches it - there's no "are you sure" step. A typo'd path, a variable pointing at the wrong folder, or copy-pasting this node into a workflow where you forgot to update folder_path can delete something you didn't mean to.

    Test on a throwaway directory first. Before wiring this into anything you'll run unattended - a loop, a scheduled batch, anything you're not watching closely - point it at a scratch folder with disposable files and confirm it does what you expect.

    It's scoped to whatever machine is actually running the job. On a hosted or serverless execution, "the folder" only exists for that run's own container, so this is mostly useful for keeping a single long-running session's disk under control between loop iterations - less relevant for a one-shot cloud job whose container gets discarded regardless.

    If you want something less blunt, this pack has it. Clear-Folder-By-Pattern, elsewhere in this same pack, lets you scope the deletion to files matching a glob instead of nuking the whole directory. If you're reaching for this node because you want to clear just your scratch PNGs or just old segments, that one's the safer fit.

    Categorycomfyui-sortlist

    Inputs (1)

    NameTypeDefaultDescription
    folder_pathSTRING

    Outputs (1)

    NameTypeDescription
    resultSTRING