SP_CacheCleanKeyString
Turn a filename into the exact cache key it was saved under
- clean_key
SP_CacheCleanKeyString is a one-wire utility that answers a deceptively annoying question: "what cache key does this file actually correspond to?" It takes a filename string, strips off the stuff that isn't part of the key, and hands you back a clean key.
The cache nodes in this pack store files under sanitized versions of their keys - my_video.mp4 becomes my_video.joblib in the cache folder, and batch counters get folded in. So when a video loader hands you my_video_00001.mp4 and you want to look up that video's cache entry, you need the same normalization the cache used. This node is that normalization, isolated and reusable.
How it works
It applies three rules in order:
- Drop the extension (
os.path.splitext). - Strip a trailing ComfyUI-style batch counter - the regex
_\d{3,6}_?$catches_00001through_999999at the end of the name. - Cut a trailing
_multisuffix, in case the filename came from a multi-slot cache entry.
So video_batch_00007.mp4 comes out as video_batch, and job_render_multi.joblib comes out as job_render. The output is a single clean_key string that matches what the pack's loaders wrote.
The inputs that matter
Just one: filename_string, marked forceInput, so you can wire it from any string-producing node - a VHS Video Loader, a filename from a save node, whatever. The node's own docs call out external list nodes and video loaders as the intended sources.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/bananasss00/ComfyUI-SP-Nodes
restart, or install "SP-Nodes" via ComfyUI Manager. No dependencies, no models - it's a few lines of string handling.
Where people get burned
It only knows the three conventions above. A filename with an unusual counter format (_vid-0007 instead of _00007) or no counter at all comes through with whatever it had. That's fine as long as you feed it names the pack produced - which is the whole point - but don't expect it to normalize arbitrary naming schemes. If your lookups keep missing, check the actual .joblib filename in the cache folder and make sure the string you're cleaning matches it.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| filename_string | STRING | Connect a string or filename here. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| clean_key | STRING | — |