first commit
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 Skycoder182
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,41 @@
|
||||
# ComfyUI Filename Tools
|
||||
|
||||
Custom nodes for ComfyUI to extract and optionally trim filenames from file paths.
|
||||
|
||||
## Features
|
||||
|
||||
- Extract filename from a full file path
|
||||
- Optionally remove everything from a specified marker
|
||||
- Automatically removes the file extension
|
||||
|
||||
## Node: Extract & Trim Filename (No Extension)
|
||||
|
||||
### Inputs
|
||||
|
||||
- `file_path` (STRING): Full path to the file (e.g., `C:/images/image_upscaled_001.png`)
|
||||
- `trim_marker` (STRING): Optional marker to trim from (e.g., `_upscaled`)
|
||||
|
||||
### Output
|
||||
|
||||
- Filename without extension, trimmed at the marker (if found)
|
||||
|
||||
### Example
|
||||
|
||||
**Input path:**
|
||||
`C:/Test/image_upscaled_001.jpg`
|
||||
**Marker:** `_upscaled`
|
||||
**Output:** `image`
|
||||
|
||||
## Installation
|
||||
|
||||
1. Clone or download this repository into your `ComfyUI/custom_nodes/` folder:
|
||||
|
||||
```
|
||||
git clone https://github.com/yourusername/comfyui-filename-tools.git
|
||||
```
|
||||
|
||||
2. Restart ComfyUI
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
import os
|
||||
|
||||
class ExtractAndTrimFilename:
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"file_path": ("STRING", {"default": "C:/Images/Image_xyz_123.png"}),
|
||||
"trim_marker": ("STRING", {"default": "", "multiline": False}),
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("processed_filename",)
|
||||
FUNCTION = "extract_and_trim"
|
||||
CATEGORY = "Utils"
|
||||
|
||||
def extract_and_trim(self, file_path, trim_marker):
|
||||
filename = os.path.basename(file_path)
|
||||
name, _ = os.path.splitext(filename)
|
||||
if trim_marker:
|
||||
index = name.find(trim_marker)
|
||||
if index != -1:
|
||||
name = name[:index]
|
||||
return (name,)
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"ExtractAndTrimFilename": ExtractAndTrimFilename
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"ExtractAndTrimFilename": "Extract & Trim Filename (No Extension)"
|
||||
}
|
||||
Reference in New Issue
Block a user