Visit ComfyUI Online for ready-to-use ComfyUI environment
Randomly select file from directory for AI artists, with optional filtering and deterministic selection using seed value.
The JNodes_SelectRandomFileFromDirectory
node is designed to help you randomly select a file from a specified directory, which can be particularly useful for tasks that require randomization or sampling from a large set of files. This node can traverse through directories, including subdirectories if specified, and filter files based on an optional file type. By using a seed value, the selection process can be made deterministic, ensuring reproducibility of results. This node is ideal for AI artists who need to randomly pick files for their projects, such as images, text files, or any other type of file, without manually browsing through directories.
This parameter specifies the directory from which the node will select a random file. It should be a string representing the path to the base directory. The node will start its search from this directory and can include subdirectories if specified. This parameter is crucial as it defines the scope of the file search.
This boolean parameter determines whether the node should include files from subdirectories within the base directory. If set to True
, the node will traverse all subdirectories; if set to False
, it will only consider files in the base directory. The default value is True
.
This string parameter allows you to filter files by their type. For example, you can specify .jpg
to only include JPEG images in the selection process. If left empty, the node will consider all file types. This parameter helps narrow down the selection to specific file types relevant to your project.
This integer parameter is used to initialize the random number generator, ensuring that the file selection process can be reproduced. By setting the same seed value, you can get the same random file selection across different runs. The default value is 0
, and it can range up to 0xffffffffffffffff
.
This output parameter returns the path of the randomly selected file as a string. The path includes the full directory structure, making it easy to locate the file. This output is essential for further processing or utilization of the selected file in your projects.
optional_file_type
parameter to filter files by type, which can be particularly useful when working with specific file formats like images or text files.include_subdirectories
to False
to speed up the file selection process.base_directory
path is correct and that it contains files. Also, check if the optional_file_type
filter is too restrictive.base_directory
path does not exist or is not accessible.base_directory
path is correct and that you have the necessary permissions to access it.0
to 0xffffffffffffffff
.optional_file_type
filter does not match any files in the directory.© Copyright 2024 RunComfy. All Rights Reserved.