Change output file names in ComfyUI

The Stable Diffusion ComfyUI is a powerful GUI for image generation, but it’s also known for its limited documentation and steep learning curve for automatic1111 users.

By default, ComfyUI generated images will be dumped in the output folder with the meaningless filename ComfyUI_00001_.png with increasing numbers.

Setting custom filenames in ComfyUI workflow

  1. Double click the filename_prefix widget in your Save Image node.
  2. Edit as follows: %date:yyyy-MM-dd%/%date:hhmmss%_%KSampler.seed%
  3. This will save files in a subfolder named with the current date.
  4. The filename will contain the current date and time.

Save Image Filename Prefix

Sample format strings

Note that the generation number (in red) is auto appended by Comfy and cannot be removed from the resulting file name

output/date/time_seed_number.png 👉 %date:yyyy-MM-dd%/%date:hhmmss%_%KSampler.seed%

You can insert the image resolution to its filename as follows:

output/date/seed/widthxheight_number.png 👉 %date:yyyy-MM-dd%/%KSampler.seed%/%Empty Latent Image.width%x%Empty Latent Image.height%

You can also add a value from any node in the format %NodeName.node_value%.

Format like automatic1111 webui

Notice this is not the exact same format, because in auto1111 the filename begins with its generation number, ensuring they are sorted by generation. In Comfy, the generation number is inserted at the end and this cannot be changed.

output/date/seed_number.png 👉 %date:yyyy-MM-dd%/%KSampler.seed%

Make sort by name also sort by generation number by prepending the time to the name:

output/date/time_seed_number.png 👉 %date:yyyy-MM-dd%/%date:hhmmss%_%KSampler.seed%

By adding the current time (%date:hhmmss%) to the beginning of the filename, sorting the folder by name will show the files in the same order they were created.

Disclaimer

The content in this post is for general information purposes only. The information is provided by the author and/or external sources and while we endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the post for any purpose. Some of the content and images used in this post may be copyrighted by their respective owners. The use of such materials is intended to be for educational and informational purposes only, and is not intended to infringe on the copyrights of any individuals or entities. If you believe that any content or images used here violate your copyright, please contact us and we will take appropriate measures to remove or attribute the material in question.