List Directory
Lists the contents of a given directory
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
if ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
- Directory Path - The path of the directory that will be listed
- Name Filter - Regex input for filtering files inside the directory (e.g.
.*pdf)
Output
- Files - Files that exist in the given directory path.
A file object is comprised of name, isDir and size fields.
files : [{
name: "Untitled.xslx",
isDir: false,
size: 1551724597
}]
Options
- Sort Type - Type for sorting the listed files.
- Ascending - Sorts the files ascending order by name
- Descending - Sorts the files descending order by name
- Last Modified - Sorts the files ascending order last by modified date
- Earliest Modified - Sorts the files descending order by last modified date
- File Properties - Select which properties to include in the output (version 23.1.0+):
- Name - Include file/directory name
- IsDir - Include directory flag
- Size - Include file size in bytes
- ModTime - Include modification time
- CreateTime - Include creation time
- Mode - Include file permissions/mode
- Absolute Path - Return absolute paths instead of just names
How It Works
The List Directory node retrieves directory contents through the following process:
- Validates that the directory path is not empty
- Reads all files and directories from the specified path
- Applies the selected sorting method (ascending, descending, modified latest, or modified earliest)
- Filters results using the Name Filter regex pattern if provided
- Constructs file objects with the selected properties (name, isDir, size, modTime, createTime, mode)
- Returns the filtered and sorted list of files in the output variable
Requirements
- Valid path to an existing directory
- Read permissions on the directory
- Sort Type must be selected
- For older versions (pre-23.1.0), name, isDir, and size are always included
Error Handling
| Error Code | Description |
|---|---|
Core.FileSystem.List.ErrOnCreate | Node configuration parsing failed |
Core.FileSystem.List.ErrOnMessage | Input message parsing failed |
Core.FileSystem.List.ErrDirPath | Directory path is empty |
Core.FileSystem.List.ErrReadDir | Cannot read directory (path doesn't exist, not a directory, or permission denied) |
Core.FileSystem.List.ErrSortType | Sort type is not selected or invalid |
Core.FileSystem.List.ErrConvert | Failed to convert file list to output format |
Usage Examples
Example 1: List All Files in a Directory
List all files in a reports directory sorted by name:
{
"dirPath": "C:\\Reports\\Monthly"
}
Configuration:
- Sort Type: Ascending
- Name Filter: (empty)
Output:
{
"files": [
{ "name": "January.xlsx", "isDir": false, "size": 1551724597 },
{ "name": "February.xlsx", "isDir": false, "size": 1448392011 }
]
}
Example 2: Filter PDF Files
List only PDF files sorted by modification date:
{
"dirPath": "D:\\Documents",
"nameFilter": ".*\\.pdf$"
}
Configuration:
- Sort Type: Last Modified
- Name Filter:
.*\.pdf$
Example 3: Get Recently Modified Files
List files sorted by most recently modified:
{
"dirPath": "C:\\Downloads"
}
Configuration:
- Sort Type: Last Modified
This returns files with the most recently modified files first, useful for processing new downloads.
Usage Notes
- The Name Filter uses regex patterns (e.g.,
.*pdfmatches all files containing "pdf") - Size is returned in bytes
- The isDir property is true for directories and false for files
- Sorting is case-sensitive for file names
- The node only lists direct children of the directory (not recursive)
- For version 23.1.0+, you can select which file properties to include in the output
- Absolute Path option (23.1.0+) returns full paths instead of just filenames
- Directory path should be trimmed of whitespace automatically
Tips
- Use regex patterns in Name Filter to select specific file types (e.g.,
.*\\.xlsx$for Excel files) - Sort by "Last Modified" to process the most recent files first in automation workflows
- Combine with Loop node to iterate through each file for processing
- Use the size property to filter out empty files or identify large files
- For recursive directory listing, use the Tree node instead
- The output can be directly used with ForEach loops to process multiple files
- Consider using Path Exists before List Directory to verify the directory exists
Related Nodes
- Tree - Recursively list all files in directory tree
- Path Exists - Check if directory exists before listing
- Read File - Read files discovered through directory listing
- Delete File/Dir - Delete files identified in the list