ComfyUI Node
Flatten Nested Files v0.2
A ComfyUI node in Eric/Images with 15 inputs and 5 outputs.
Flatten Nested Files v0.2
- status_message
- files_moved
- paired_files_moved
- stats_json
- log_output
◄main_directory►
◄operation_modeflatten_only►
◄file_typesimages_only►
◄flatten_depth0►
◄respect_paired_filestrue►
◄skip_organized_folderstrue►
◄organize_by_typefalse►
◄sidecar_handlingkeep_with_images►
◄remove_empty_folderstrue►
◄dry_runfalse►
◄handle_conflictsrename►
◄max_scan_depth100►
◄custom_type_mappings►
◄custom_folder_mappings►
◄preserve_source_foldernone►
CategoryEric/Images
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| main_directory | STRING | Main directory where all files will be moved to | |
| operation_mode | COMBO | flatten_only | Choose operation mode: • flatten_only: Move all files directly into main_directory (NO type subfolders) • flatten_and_organize: Move files AND create type subfolders (images/, movies/, etc.) • organize_only: Don't move files up, just organize them in their current locations Note: organize_by_type parameter can override flatten_only to add type folders |
| file_typesopt | COMBO | images_only | Which files to process: • images_only: .jpg, .png, .webp, .gif, etc. • all_media: Images + videos (.mp4, .mov, etc.) • all_files: Everything including .txt, .pdf, etc. |
| flatten_depthopt | INT | 00–10 | Flatten nested folders to this depth: • 0 = Move ALL files to main directory • 1 = Keep 1st level subfolders, flatten everything inside them • 2 = Keep 2 levels, flatten below that Example: If main=instagram and depth=1, processes each profile folder (alisha.maghi/, 777luckyfish/) independently |
| respect_paired_filesopt | BOOLEAN | true | Keep paired files together (e.g., photo.jpg + photo.xmp + photo.txt). Paired files share the same base filename and are moved as a group. |
| skip_organized_foldersopt | BOOLEAN | true | Skip folders that already have type organization (contain images/, movies/, text/ subfolders). Useful to avoid re-organizing already processed directories. |
| organize_by_typeopt | BOOLEAN | false | Create type-based subfolders: • images/ for .jpg, .png, etc. • movies/ for .mp4, .mov, etc. • text/ for .txt, .pdf, .md • sidecars/ for .xmp, .json (unless kept with images) • other/ for unrecognized types When True: Always creates type folders (even with flatten_only mode) When False with flatten_only: All files go directly into main_directory |
| sidecar_handlingopt | COMBO | keep_with_images | Where to put sidecar/metadata files: • keep_with_images: Put .xmp/.json/.txt in images/ folder • separate_folder: Put all sidecars in sidecars/ folder • keep_txt_only: Only .txt with images, others to sidecars/ |
| remove_empty_foldersopt | BOOLEAN | true | Delete empty subdirectories after moving files. Leaves a clean directory structure with no leftover empty folders. |
| dry_runopt | BOOLEAN | false | Preview mode - show what WOULD be moved without actually moving anything. Great for testing settings before committing changes. |
| handle_conflictsopt | COMBO | rename | How to handle duplicate filenames: • rename: Add (1), (2), etc. to filename • skip: Leave original, don't move duplicate • overwrite: Replace existing file with new one |
| max_scan_depthopt | INT | 1001–200 | Maximum folder nesting depth to scan. Increase if you have very deeply nested folders (46+ levels). Prevents infinite loops and excessive scanning. |
| custom_type_mappingsopt | STRING | JSON mapping file extensions to custom folder names. Example: { ".pdf": "documents", ".cr2": "raw_photos", ".psd": "photoshop" } Files with these extensions go to specified folders instead of default type folders. | |
| custom_folder_mappingsopt | STRING | JSON mapping file TYPES to custom folder names. Example: { "movies": "videos", "images": "photos", "text": "documents" } Renames the default type folders (images→photos, movies→videos, etc.). | |
| preserve_source_folderopt | COMBO | none | Add original folder name to filename to preserve context: • none: photo.jpg (no change) • prefix: alisha.maghi_photo.jpg • suffix: photo_alisha.maghi.jpg Useful when flattening to avoid name conflicts and maintain source info. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| status_message | STRING | — |
| files_moved | INT | — |
| paired_files_moved | INT | — |
| stats_json | STRING | — |
| log_output | STRING | — |