Nodes/petty-paint-comfyui-node/Petty Paint Ensure Directory
ComfyUI Node

Petty Paint Ensure Directory

Make sure a folder exists before a save node fails on you

By mephisto83·Created 2 years ago·Updated 2 years ago· 3
Petty Paint Ensure Directory
  • value
  • data

Every ComfyUI regular has hit it: the workflow ran fine yesterday, today the save node fails because some folder got cleaned up or never existed. PettyPaintEnsureDirectory is the guard for that. Give it a path and it creates the directory if it's missing - os.makedirs(path, exist_ok=True) - then hands the same path back, untouched. Nothing else happens. It's the filesystem equivalent of a seatbelt: you notice it exactly when it does its job and you'd have crashed without it.

It's a genuinely community-requested thing, too. In a r/comfyui thread titled "Is there a node to ensure a given directory exists?", the asker's save-text node kept failing when they forgot to pre-create the output folder - and their resolution was literally this node: "I found one. It is called 'Petty Paint Ensure Directory' and works fine." That's the real-world niche: a one-line utility that saves you from folder-missing failures in batch and pipeline work.

How it works

Feed it any path string; it creates the directory (and any missing parents, thanks to makedirs with exist_ok=True), so C:/runs/out/subfolder gets the whole chain created in one shot. If the folder already exists it's a no-op. The pass-through behavior is the key design choice: because it returns value unchanged, you can wire it inline in a chain - path node → EnsureDirectory → whatever consumes the path - and it costs you nothing on the happy path.

The inputs and outputs

  • value - any type (*), practically a directory path string.
  • Output: data (*) - the same value, unchanged.

Installing it

It's in the petty-paint pack:

cd ComfyUI/custom_nodes
git clone https://github.com/mephisto83/petty-paint-comfyui-node

Restart ComfyUI, or install via ComfyUI Manager searching "petty-paint-comfyui-node". Declared dependency: Flask==2.1.2, unused here.

Common issues

The one thing to remember: it creates directories on your filesystem, not inside ComfyUI's sandboxed output convention. If you hand it a path outside what you expected, it will create that too - permissions permitting - and silently. That's powerful and a little dangerous; keep paths explicit and predictable. The node also swallows errors: if creation fails (bad permission, illegal path), it prints to the console and returns the value anyway, so a failure doesn't break the graph - which means a save node downstream can still fail afterward. Check the console if things are weird. But for the "I keep forgetting the folder" problem, it's exactly right.

CategoryPettyPaint

Inputs (1)

NameTypeDefaultDescription
value*

Outputs (1)

NameTypeDescription
data*