Skip to main content

The "file_list" Function

Syntax#

file_list(dname, attr, [recurse]);
ArgumentTypeDescription
dnamestringThe full path of the target directory, including drive letter
attrinteger/constantEnables filtering results as directories (fa_directory) or files (anything else)
[recurse]booleanOptional: Enables including subdirectories in scan results (disabled by default)

Description#

Scans a directory and returns the contents as a ds_list, including relative paths (if any), filenames, and extensions.

The attribute filter and recursive options can only be used on Windows. All other platforms should set attr to 0 and ignore the optional recurse argument.

If the attribute filter is supported and set to fa_directory, only directories will be returned. This is the only supported filter, and all other options will return a list of files instead.

caution

To achieve best processing speed, files without extensions are not supported by this script.

important

By default, this script can only be used to scan directories within working_directory or elsewhere previously granted access via the get_save_filename function. On desktop platforms, this limitation can be removed by disabling the filesystem sandbox in Game Settings.

Example#

var dirs = file_list("C:\\my\\folder", fa_directory, true);
var files = file_list("C:\\my\\folder", 0);