Save Image filname_prefix error
I try create a new folder name as date and use the seed as image file name, I used " %date:yyyy-MM-dd%/%KSampler.seed%", It run normally when just deploy the node. with fill the code within the save image node.
but once "convert filename_prefix to input" and use primitive node send a string to filename_prefix on save image node. the error will show up. even convert filename_prefix input back to widget, the error still stay.
Anyone know how I can send string to the save image node?
Hello! I've just had the same error:
- OS Name: Microsoft Windows 11 Pro Version 10.0.22631 Build 22631
- Navigator: MS Edge Version 122.0.2365.59 (Official build) (64-bit)
How do I fix?
in web\scripts\utils.js path, replace in line 30 the following:
change
return value.replace(/%([^%]+)%/g, function (match, text) {
for (Option 1)
return value.replace(/\%([^%]+)\%/g, function (match, text) {
or (Option 2)
return value.replace(new RegExp('%([^%]+)%', 'g'), function (match, text) {
Why it failed? maybe some Javascript update 🤷♂️. Maybe we should check another OS/Navigator before create some official fix
Hello! I've just had the same error:
* OS Name: Microsoft Windows 11 Pro Version 10.0.22631 Build 22631 * Navigator: MS Edge Version 122.0.2365.59 (Official build) (64-bit)How do I fix? in
web\scripts\utils.jspath, replace in line30the following: changereturn value.replace(/%([^%]+)%/g, function (match, text) {for (Option 1)
return value.replace(/\%([^%]+)\%/g, function (match, text) {or (Option 2)
return value.replace(new RegExp('%([^%]+)%', 'g'), function (match, text) {Why it failed? maybe some Javascript update 🤷♂️. Maybe we should check another OS/Navigator before create some official fix
Neither of those options fixed the problem.
Update
I've fixed this error by replacing the Primitive node with a widget in the Save Image node itself as explained here, this also makes the workflow cleaner.
It's basically an issue with strings not being converted properly when supplied as inputs.
In CSharp land we would use an @string to make it as-is rather than attempting to cancel out the \ characters with a negation, e.g.: \\. Not sure what the solution is in Python.
You can use primitives or other string generators and they return this error:
Details
ComfyUI Error Report
Error Details
- Node Type: SaveImage
- Exception Type: OSError
- Exception Message: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'E:\AI\ComfyUI\output\%date:yyyy-MM%\%date:yyyy-MM-d%'
Stack Trace
File "E:\AI\ComfyUI\execution.py", line 323, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\execution.py", line 198, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "E:\AI\ComfyUI\execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\nodes.py", line 1502, in save_images
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\folder_paths.py", line 371, in get_save_image_path
counter = max(filter(lambda a: os.path.normcase(a[1][:-1]) == os.path.normcase(filename) and a[1][-1] == "_", map(map_filename, os.listdir(full_output_folder))))[0] + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
System Information
- ComfyUI Version: v0.2.3-3-g6632365
- Arguments: E:\AI\ComfyUI\main.py --front-end-version Comfy-Org/ComfyUI_frontend@latest
- OS: nt
- Python Version: 3.11.6 (tags/v3.11.6:8b6ee5b, Oct 2 2023, 14:57:12) [MSC v.1935 64 bit (AMD64)]
- Embedded Python: false
- PyTorch Version: 2.4.0+cu121
Devices
- Name: cuda:0 NVIDIA GeForce RTX 4090 : cudaMallocAsync
- Type: cuda
- VRAM Total: 25756696576
- VRAM Free: 17027089378
- Torch VRAM Total: 7650410496
- Torch VRAM Free: 677692386
Logs
2024-10-13 17:42:33,384 - root - INFO - Total VRAM 24564 MB, total RAM 64729 MB
2024-10-13 17:42:33,384 - root - INFO - pytorch version: 2.4.0+cu121
2024-10-13 17:42:33,384 - root - INFO - Set vram state to: NORMAL_VRAM
2024-10-13 17:42:33,384 - root - INFO - Device: cuda:0 NVIDIA GeForce RTX 4090 : cudaMallocAsync
2024-10-13 17:42:34,097 - root - INFO - Using pytorch cross attention
2024-10-13 17:42:35,882 - root - INFO - Downloading frontend(Comfy-Org_ComfyUI_frontend) version(1.3.19) to (E:\AI\ComfyUI\web_custom_versions\Comfy-Org_ComfyUI_frontend\1.3.19)
2024-10-13 17:42:37,709 - root - INFO - [Prompt Server] web root: E:\AI\ComfyUI\web_custom_versions\Comfy-Org_ComfyUI_frontend\1.3.19
2024-10-13 17:42:39,084 - albumentations.check_version - INFO - A new version of Albumentations is available: 1.4.18 (you have 1.4.13). Upgrade using: pip install -U albumentations. To disable automatic update checks, set the environment variable NO_ALBUMENTATIONS_UPDATE to 1.
2024-10-13 17:42:40,473 - root - INFO -
Import times for custom nodes:
2024-10-13 17:42:40,473 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\websocket_image_save.py
2024-10-13 17:42:40,473 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\make_model_tileable.py
2024-10-13 17:42:40,473 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\k_centroid_downscale.py
2024-10-13 17:42:40,473 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\remove_background.py
2024-10-13 17:42:40,473 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\palettize.py
2024-10-13 17:42:40,473 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\patterngen.py
2024-10-13 17:42:40,473 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\SDXL_sizing
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI-Better-Numbers
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\Skimmed_CFG
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI_ADV_CLIP_emb
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI-Better-Strings
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\comfyui-diffusion-cg
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI-ComfyCouple
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI-AutomaticCFG
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI-Custom-Scripts
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI-GGUF
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI_IPAdapter_plus
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\comfyui_controlnet_aux
2024-10-13 17:42:40,474 - root - INFO - 0.0 seconds: E:\AI\ComfyUI\custom_nodes\comfyui-workspace-manager
2024-10-13 17:42:40,474 - root - INFO - 0.4 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI-Impact-Pack
2024-10-13 17:42:40,474 - root - INFO - 0.8 seconds: E:\AI\ComfyUI\custom_nodes\mask_ops.py
2024-10-13 17:42:40,474 - root - INFO - 0.9 seconds: E:\AI\ComfyUI\custom_nodes\ComfyUI-Inspyrenet-Rembg
2024-10-13 17:42:40,474 - root - INFO -
2024-10-13 17:42:40,488 - root - INFO - Starting server
2024-10-13 17:42:40,488 - root - INFO - To see the GUI go to: http://127.0.0.1:8188
2024-10-13 17:44:05,833 - root - INFO - got prompt
2024-10-13 17:44:06,331 - root - INFO - Using pytorch attention in VAE
2024-10-13 17:44:06,332 - root - INFO - Using pytorch attention in VAE
2024-10-13 17:44:07,038 - root - INFO - model weight dtype torch.float16, manual cast: None
2024-10-13 17:44:07,048 - root - INFO - model_type EPS
2024-10-13 17:44:13,650 - root - INFO - Using pytorch attention in VAE
2024-10-13 17:44:13,819 - root - INFO - Using pytorch attention in VAE
2024-10-13 17:44:14,301 - root - INFO - Requested to load SDXLClipModel
2024-10-13 17:44:14,301 - root - INFO - Loading 1 new model
2024-10-13 17:44:14,308 - root - INFO - loaded completely 0.0 1560.802734375 True
2024-10-13 17:44:18,606 - root - INFO - Requested to load SDXLClipModel
2024-10-13 17:44:18,606 - root - INFO - Loading 1 new model
2024-10-13 17:44:20,376 - root - INFO - loaded completely 0.0 1560.802734375 True
2024-10-13 17:44:20,664 - root - INFO - Requested to load SDXL
2024-10-13 17:44:20,664 - root - INFO - Loading 1 new model
2024-10-13 17:44:23,864 - root - INFO - loaded completely 0.0 4897.0483474731445 True
2024-10-13 17:44:29,147 - root - INFO - Requested to load AutoencoderKL
2024-10-13 17:44:29,147 - root - INFO - Loading 1 new model
2024-10-13 17:44:29,168 - root - INFO - loaded completely 0.0 159.55708122253418 True
2024-10-13 17:44:29,453 - root - ERROR - !!! Exception during processing !!! [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'E:\\AI\\ComfyUI\\output\\%date:yyyy-MM%\\%date:yyyy-MM-d%'
2024-10-13 17:44:29,455 - root - ERROR - Traceback (most recent call last):
File "E:\AI\ComfyUI\execution.py", line 323, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\execution.py", line 198, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "E:\AI\ComfyUI\execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\nodes.py", line 1502, in save_images
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\folder_paths.py", line 371, in get_save_image_path
counter = max(filter(lambda a: os.path.normcase(a[1][:-1]) == os.path.normcase(filename) and a[1][-1] == "_", map(map_filename, os.listdir(full_output_folder))))[0] + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'E:\\AI\\ComfyUI\\output\\%date:yyyy-MM%\\%date:yyyy-MM-d%'
2024-10-13 17:44:29,456 - root - INFO - Prompt executed in 23.27 seconds
2024-10-13 17:46:12,078 - root - INFO - got prompt
2024-10-13 17:46:12,429 - root - ERROR - !!! Exception during processing !!! [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'E:\\AI\\ComfyUI\\output\\%date:yyyy-MM%\\%date:yyyy-MM-d%'
2024-10-13 17:46:12,429 - root - ERROR - Traceback (most recent call last):
File "E:\AI\ComfyUI\execution.py", line 323, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\execution.py", line 198, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\execution.py", line 169, in _map_node_over_list
process_inputs(input_dict, i)
File "E:\AI\ComfyUI\execution.py", line 158, in process_inputs
results.append(getattr(obj, func)(**inputs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\nodes.py", line 1502, in save_images
full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\AI\ComfyUI\folder_paths.py", line 371, in get_save_image_path
counter = max(filter(lambda a: os.path.normcase(a[1][:-1]) == os.path.normcase(filename) and a[1][-1] == "_", map(map_filename, os.listdir(full_output_folder))))[0] + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'E:\\AI\\ComfyUI\\output\\%date:yyyy-MM%\\%date:yyyy-MM-d%'
2024-10-13 17:46:12,431 - root - INFO - Prompt executed in 0.01 seconds
Attached Workflow
Please make sure that workflow does not contain any sensitive information such as API keys or passwords.
Workflow too large. Please manually upload the workflow from local file system.
Very easy to reproduce.
It's worth noting that specifically this occurs when using nested directories with %% symbols. Plugging in a values such as test some\test and yet\another\test will produce images successfully.
Even typing in %date:yyyy-MM-d% on its own is fine.
It's when you use something like %date:yyyy-MM%\test that it fails with the error above.
of "test" will give you a normal output like you may expect.
Even more specifically, it's when the subdirectory comes after the variable, such as %date:yyyy-MM%\test. In comparison, test\%date:yyyy-MM% works fine.
Looking at the following code
https://github.com/comfyanonymous/ComfyUI/blob/3c72c89a52d5fa8fc4ae9bf83f8bbe3c850dd7c6/folder_paths.py#L342-L352
It appears that only some of the fancy string interpretation is occurring within the SaveImage node.
If you breakpoint and pass in a string widget on the node itself, it is passed in directly to the node input as a date, such as 2024 instead of %date:yyyy% rather than being converted by anything within the SaveImage class.
The issue lies in the fact that if you pass in a primitive you get %date:yyyy% (etc.) being passed in rather than evaluated correctly.
Well, as far as I can tell, the execution logic to parse %date% must be pretty high somewhere.
Interestingly enough, I was actually able to move the exact same working prompt from a string primitive back to the input node of the Save Image node and it didn't recalculate and thus the workflow failed.
So looks like the %date% gets parsed and cached on the UI side somewhere.
(Disclaimer: This is speculation at this point)
Found it.
https://github.com/comfyanonymous/ComfyUI/blob/14eba07acd28d5b0fc250e493ab7751bd9b9b43e/web/assets/index-BMC1ey-i.js#L3956-L3980
So basically, it's calculated here, using exactly, and only, the SaveImage node to parse some fancy string changes. This means it isn't respected and doesn't work if you do this anywhere else.
That... Sucks a bit.