Tree
Lists files and directories in the 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 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.
Output
- Files - List of files.
Options
- Only Directories - Only directories will be listed.
- Created After - Only files after this creating date.
- Modified After - Only files modified after this date.
How It Works
The Tree node recursively traverses directory structures through the following process:
- Validates that the directory path is not empty
- Parses the Created After and Modified After date filters (format: ISO 8601)
- Walks the entire directory tree using filepath.Walk
- For each item found:
- Checks creation time against Created After filter
- Checks modification time against Modified After filter
- If Only Directories is enabled, skips files
- Builds a hierarchical tree structure
- Returns a nested tree of files and directories with their properties
Requirements
- Valid path to an existing directory
- Read permissions on the directory and all subdirectories
- Date filters must be in ISO 8601 format:
2006-01-02T15:04:05.999Z - Valid date values for Created After and Modified After filters
Error Handling
| Error Code | Description |
|---|---|
Core.FileSystem.Tree.ErrOnCreate | Node configuration parsing failed |
Core.FileSystem.Tree.ErrOnMessage | Input message parsing failed |
Core.FileSystem.Tree.ErrDirPath | Directory path is empty |
Core.FileSystem.Tree.ErrCreatedAfter | Created After filter date is not valid |
Core.FileSystem.Tree.ErrModifiedAfter | Modified After filter date is not valid |
Core.FileSystem.Tree.ErrWalk | Failed to walk directory tree (permission denied or I/O error) |
Core.FileSystem.Tree.ErrUnmarshalTree | Failed to convert tree structure to output format |
Usage Examples
Example 1: Get Full Directory Tree
Get the complete hierarchical structure of a project directory:
{
"dirPath": "C:\\Projects\\MyApp"
}
Configuration:
- Only Directories: false
- Created After: (empty)
- Modified After: (empty)
Output:
{
"files": [
{
"isDir": true,
"name": "src",
"size": 0,
"files": [
{ "isDir": false, "name": "main.go", "size": 1024, "files": [] }
]
}
]
}
Example 2: List Only Directory Structure
Get only the directory hierarchy without files:
{
"dirPath": "D:\\Archive"
}
Configuration:
- Only Directories: true
This returns only folders in the tree, useful for visualizing folder structure.
Example 3: Find Recently Modified Files
Get files modified after a specific date:
{
"dirPath": "C:\\Reports",
"modifiedAfter": "2024-01-01T00:00:00.000Z"
}
Configuration:
- Modified After:
2024-01-01T00:00:00.000Z
Returns a tree containing only files modified after January 1, 2024.
Usage Notes
- The output is a hierarchical tree structure with nested files arrays
- Each item contains:
isDir,name,size, andfiles(array of children) - Date filters use ISO 8601 format with milliseconds and timezone (Z for UTC)
- Created After filter applies to directories; Modified After applies to files
- The walk operation is recursive and traverses all subdirectories
- Files and directories are organized hierarchically, preserving the folder structure
- Empty date filters are treated as the beginning of time (no filtering)
- Symbolic links are followed during the tree walk
Tips
- Use date filters to find recently created or modified files in large directory trees
- Set Only Directories to true to map out folder structures without file clutter
- The tree structure is ideal for displaying in UI or generating reports
- Combine with JSON operations to search for specific files in the tree
- Be cautious with very large directory trees as they can consume significant memory
- Use List Directory instead if you only need a flat list of files in one directory
- Date filters are particularly useful for incremental backups or change detection
- The hierarchical structure preserves the complete directory organization
Related Nodes
- List Directory - List files in a single directory (non-recursive)
- Path Exists - Check if directory exists before walking tree
- Read File - Read files discovered in the tree
- Delete File/Dir - Delete files or directories from the tree