ComfyUI-APZmedia-cleanName-from-string

ComfyUI-APZmedia-cleanName-from-string
★ 8

文件命名文本清理VFX管线路径安全
将任意字符串清洗并规范为安全文件名:移除非法字符、修剪空白并生成适用于VFX管线的文件名和路径片段。
💡 在VFX流程中将任意字符串快速转换为安全文件名
🍴 2 Forks💻 Python🔄 2025-08-11
📦
网盘下载
复制链接后前往夸克网盘下载
https://pan.quark.cn/s/f414772aa5c3
📦 requirements.txt
unidecode
📄 README

APZmedia Naming Tools

Overview

This package provides a comprehensive set of naming tools for ComfyUI that streamline text processing for VFX file naming, file path generation, and primitive value selection. The tools include the Clean File Name Node, Generate File Path Node, APZmedia Standard Filename Builder, and Primitive Selector Nodes, all designed to fit common conventions in VFX pipelines. These tools help sanitize text, create valid filenames, generate file paths, and provide primitive values for tagging and other operations.

Features

1. APZmedia Clean File Name Node

  • Text Sanitization: Removes invalid characters and replaces them with specified characters
  • Accent Handling: Converts accented characters to their unaccented equivalents
  • Character Limit Control: Truncates text to specified maximum length
  • Prefix Support: Adds user-defined prefix to cleaned text
  • Customizable Replacement: Specifies character to replace invalid characters
  • 2. APZmedia Generate File Path

  • VFX Folder Structure: Dynamically generates file paths based on project components
  • Toggle Components: Each component can be included or excluded for flexible path generation
  • OS-Compatible Paths: Automatically uses correct file path separators for the operating system
  • Flexible Structure: Build paths like /root/project/episode/shot/pass based on your needs
  • 3. APZmedia Standard Filename Builder

  • Customizable Segments: Concatenate project, episode, shot, and pass names
  • Flexible Inclusion: Toggle segments on/off to include only relevant components
  • Delimiter Control: Specify custom delimiters (hyphen, underscore, etc.)
  • Standardized Naming: Maintain consistent file naming across projects
  • 4. APZmedia Read Widget

  • Simple Text Input: Takes any text input and outputs it as a string
  • Widget Reading: Can be used to read values from other nodes’ widgets
  • Clean Interface: Simple, focused functionality following cg-quicknodes pattern
  • String Output: Provides text values for use in naming operations
  • 5. APZmedia Image Filename

  • Filename Extraction: Extracts original filenames from Load Image nodes
  • Extension Handling: Provides both full filename and filename without extension
  • Metadata Access: Reads filename from image metadata and attributes
  • Fallback Support: Handles cases where filename is not available
  • Input and Output Types

    APZmedia Clean File Name Node

  • Input Types:
  • input_text (STRING): The text to be cleaned
  • replacement_char (STRING): Character to replace invalid characters (default: -)
  • invalid_chars (STRING): Characters to be removed (default: #%&{}\\<>*?/ $!'\":@+|=.`)
  • prefix (STRING): Prefix to prepend to the filename
  • char_limit (INT): Maximum length of the output string (default: 255)
  • Output Types:
  • cleaned_text (STRING): The sanitized and truncated text string
  • APZmedia Generate File Path

  • Input Types:
  • root_folder (STRING): The root directory for the project (e.g., /mnt/projects)
  • project_name (STRING): The name of the VFX project or show (e.g., Starwars)
  • episode_name (STRING): The episode or sequence name (optional)
  • shot_name (STRING): The shot number or identifier (e.g., 0010)
  • pass_name (STRING): The type of pass (e.g., compositing, animation)
  • toggle_root_folder (INCLUDE/EXCLUDE): Whether to include the root folder
  • toggle_project_name (INCLUDE/EXCLUDE): Whether to include the project name
  • toggle_episode_name (INCLUDE/EXCLUDE): Whether to include the episode name
  • toggle_shot_name (INCLUDE/EXCLUDE): Whether to include the shot name
  • toggle_pass_name (INCLUDE/EXCLUDE): Whether to include the pass type
  • Output Types:
  • generated_path (STRING): The generated file path with correct OS separators
  • APZmedia Standard Filename Builder

  • Input Types:
  • project_name (STRING): The project or show name (optional)
  • episode_name (STRING): The episode or sequence name (optional)
  • shot_name (STRING): The shot number or identifier (e.g., 0010)
  • pass_name (STRING): The type of pass (e.g., compositing, animation)
  • delimiter (STRING): The character to separate segments (default: -)
  • toggle_project_name (INCLUDE/EXCLUDE): Whether to include project name
  • toggle_episode_name (INCLUDE/EXCLUDE): Whether to include episode name
  • toggle_shot_name (INCLUDE/EXCLUDE): Whether to include shot name
  • toggle_pass_name (INCLUDE/EXCLUDE): Whether to include pass name
  • Output Types:
  • concatenated_name (STRING): The concatenated filename with selected delimiter
  • APZmedia Read Widget

  • Input Types:
  • text (STRING): Text input to be output as string
  • Output Types:
  • text (STRING): The input text as a string output
  • APZmedia Image Filename

  • Input Types:
  • image (IMAGE): Image input from Load Image node
  • Output Types:
  • filename (STRING): The complete filename with extension
  • filename_without_ext (STRING): The filename without extension
  • How They Work

    APZmedia Clean File Name Node

  • Accent Conversion: Converts accented characters to unaccented equivalents
  • Space Replacement: Replaces spaces with the specified replacement character
  • Invalid Character Removal: Removes characters defined in invalid_chars
  • Consecutive Character Cleanup: Removes duplicate replacement characters
  • Prefix Addition: Adds the user-defined prefix
  • Length Truncation: Ensures the final text doesn’t exceed the character limit
  • APZmedia Generate File Path

  • Component Selection: Evaluates which components should be included based on toggles
  • Path Assembly: Builds the path by concatenating selected components
  • OS Path Joining: Uses os.path.join() for correct path separators
  • Output Generation: Returns the complete file path
  • APZmedia Standard Filename Builder

  • Segment Evaluation: Checks which segments should be included based on toggles
  • Name Assembly: Collects all enabled segments into a list
  • Delimiter Application: Joins segments using the specified delimiter
  • Output Generation: Returns the concatenated filename
  • APZmedia Read Widget

  • Text Input: Accepts any text input
  • String Output: Returns the input as a string output
  • Widget Integration: Can be used to read values from other nodes
  • APZmedia Image Filename

  • Image Analysis: Examines the image object for filename metadata
  • Filename Extraction: Attempts multiple methods to find the original filename
  • Extension Processing: Separates filename from extension
  • Fallback Handling: Provides “unknown” if no filename is found
  • Use Cases

    Filename Tagging

  • Use Read Widget for text inputs and widget values
  • Use Clean File Name to sanitize user input
  • Use Standard Filename Builder for structured naming
  • Use Image Filename to preserve original image names
  • Path Generation

  • Use Generate File Path for VFX pipeline structures
  • Combine with Read Widget for dynamic path components
  • Workflow Integration

  • Chain multiple nodes for complex naming systems
  • Use Read Widget outputs as inputs to filename builders
  • Combine with ComfyUI’s image generation for automatic file naming
  • Extract original filenames and preserve them in new naming schemes
  • Installation

  • Clone or download this repository to your ComfyUI custom_nodes directory
  • Install dependencies: pip install -e .
  • Restart ComfyUI to load the new naming tools
  • Find tools in the “APZmedia” category in the node menu
  • Dependencies

  • unidecode: For accent character conversion
  • ComfyUI: The main application
  • License

    MIT License – See LICENSE file for details.

    Author

    Pablo ApiolazzaAPZmedia

    Support

    For issues, feature requests, or questions, please visit the GitHub repository.