Create Directory
AI-generatedOverview
This node creates directories on the file system, supporting nested directory creation with customizable options. It is useful when automating workflows that require preparing folder structures before saving files or organizing data. For example, you can create a new project folder with subfolders in one step, or ensure parent directories exist before writing output files.
Properties
| Name | Meaning |
|---|---|
| Directory Path | The full path of the directory to create. |
| Creation Options | A collection of options controlling how the directory is created: |
| - Recursive Creation | Whether to create parent directories if they don't exist (true/false). |
| - Directory Mode (Permissions) | Directory permissions in octal notation (e.g., "0755"). |
| - Skip if Exists | Whether to skip creation without error if the directory already exists (true/false). |
| - Create Parent Structure Only | Whether to create only the parent directories, not the final directory itself (true/false). |
Output
The node outputs an array of JSON objects, each representing the result of creating a directory for the corresponding input item. Each output object contains:
success: Boolean indicating if the operation succeeded.created: Boolean indicating if the directory was actually created.skipped: Boolean indicating if creation was skipped because the directory existed and skipping was enabled.message: Informational message about the operation (present when skipped).path: The absolute path of the directory created or checked.name: The base name of the directory.parentDirectory: The parent directory path.creationTime: Time in milliseconds taken to create the directory.createdAt: ISO timestamp of when the directory was created.permissions: Object containing:mode: Numeric mode of the directory permissions.octal: Octal string representation of the permissions.
owner: Object containing:uid: User ID of the owner.gid: Group ID of the owner.
recursive: Boolean indicating if recursive creation was used.parentsOnly: Boolean indicating if only parent directories were created.
If the node encounters an error and is set to continue on failure, it outputs an object with:
success: falsecreated: falseerror: Error messagepath: The directory path attempted
The node does not output binary data.
Dependencies
- Requires access to the local file system where n8n is running.
- Uses Node.js built-in modules:
fs(filesystem) andpath. - No external API keys or services are required.
Troubleshooting
- Common issues:
- Invalid or empty directory path will cause an error.
- Permission denied errors if the n8n process lacks rights to create directories at the specified location.
- If the directory exists and "Skip if Exists" is false, the node throws an error.
- Error messages:
"Directory path is required": Ensure the directory path property is set and not empty."Directory already exists: <path>": Either enable "Skip if Exists" or choose a different path.- Filesystem permission errors: Check user permissions for the target directory path.
- To resolve errors, verify paths, adjust permissions, and configure options accordingly.