Nodes/ComfyUI-ToolBox/FolderDeleter
ComfyUI Node

FolderDeleter

Batch-delete files from your AutoDL box without a terminal — and one big warning

By hben35096·Created 2 years ago·Updated 2 years ago· 7
FolderDeleter
    • STRING
    target_path
    file_name

    This node deletes things. Read that sentence twice, because it's the whole story: FolderDeleter removes files, folders, and symlinks from a target directory on your machine, from inside the ComfyUI graph. It's part of ComfyUI-ToolBox's file-management trio, and it's genuinely handy for cleaning up AutoDL storage between sessions - cloud boxes fill up fast, and SSHing in just to rm a few checkpoints is a chore. Just be aware you're pointing a graph node at your filesystem with a delete button attached.

    How it works

    The node joins file_name onto /root/<target_path> (like the other common nodes in this pack, it's anchored to /root - more on that below), then for each entry it figures out what it's dealing with and removes it appropriately:

    • a symlink gets os.unlink() - the link itself, not what it points to
    • a file gets os.remove()
    • a directory gets shutil.rmtree() - that's recursive, it removes the folder and everything inside it

    The clever bit is file_name being multiline: put one name per line and it batch-deletes them all in a single run. Each deletion produces its own status line, which the node joins together and returns as its single STRING output - a running log of what got deleted, skipped, or errored.

    The inputs that matter

    • target_path - the directory to operate in, relative to /root. So to work in /root/models/checkpoints, you type models/checkpoints.
    • file_name - one filename or folder name per line. This is the batch list. Blank lines are skipped.

    The output is the results log as a STRING - wire it to a text display if you want to read it without opening the console.

    The warning, spelled out

    This node gives you no confirmation dialog, no undo, and no trash bin. A typo in target_path plus a folder name in file_name equals shutil.rmtree on the wrong directory, recursively. It also happily deletes dotfiles - there's no "skip hidden" filter like FolderViewe has. And remember the /root anchoring: it's hardcoded, so on a local machine this is deleting under whatever /root resolves to on your box. Before you run it, run FolderViewe on the same target_path and look at what's actually there. Look, then delete. That pairing is the safe workflow.

    Installing it

    Same tiny install as the rest of the pack:

    # via ComfyUI Manager: search "ComfyUI-ToolBox", install, restart
    cd ComfyUI/custom_nodes
    git clone https://github.com/hben35096/ComfyUI-ToolBox
    

    No model files. The only dependency is codewithgpu (installed automatically by Manager; pip install -r requirements.txt if you cloned by hand).

    Where people trip up

    • Recursion is real. file_name pointing at a directory deletes the whole tree. There's no way to make it non-recursive.
    • Missing path vs. missing name. If target_path doesn't exist, you get a hint telling you it's not a valid path. If file_name is empty, you get "please enter a filename". Both are clear, at least.
    • Node disappearing after install. If you don't see FolderDeleter in the node list at all, the pack's commonly_node.py failed to import - almost always because codewithgpu isn't installed. pip show codewithgpu tells you in one line.

    Is this the node you'd reach for on a home PC? Probably not - file managers and the OS trash can do this more safely. But on a rented AutoDL box with limited storage and no GUI, a graph-native deleter is a real time-saver. Just double-check your paths first.

    CategoryToolBox

    Inputs (2)

    NameTypeDefaultDescription
    target_pathSTRING
    file_nameSTRING

    Outputs (1)

    NameTypeDescription
    STRINGSTRING