Overview
This node allows users to delete files or folders on a Samba (SMB2) server. It connects to the SMB server and removes the specified file or folder based on the provided path. This operation is useful for automating cleanup tasks, managing remote file storage, or integrating SMB file management into workflows.
Practical examples:
- Automatically deleting temporary files after processing.
- Removing outdated reports or logs from a shared network drive.
- Cleaning up user-uploaded files after a certain period.
Properties
| Name | Meaning |
|---|---|
| Path | The full file path of the file or folder to delete, e.g., /public/documents/file.txt. |
| Options | Collection of options: - Folder: Boolean indicating whether folders can be deleted (true/false). |
Output
The output consists of an array of items corresponding to each input item processed. Each output item contains the original input data, potentially augmented with error information if deletion failed and "Continue On Fail" is enabled.
- On successful deletion, the output item is the same as the input item without additional fields.
- On failure (if continuing on fail), the output item includes an
errorfield in its JSON describing the failure reason.
No binary data is produced by this operation.
Dependencies
- Requires connection to a Samba (SMB2) server.
- Needs valid credentials for authentication to the SMB server.
- Uses internal helper functions to establish the SMB connection and handle errors.
- No external API keys beyond SMB authentication are required.
Troubleshooting
Common issues:
- Incorrect file/folder path leading to "file not found" errors.
- Insufficient permissions to delete the target file or folder.
- Attempting to delete a folder without enabling the "Folder" option.
- Network connectivity problems with the SMB server.
Error messages:
"Failed to delete file: <error message>": Indicates deletion failed due to permission issues, non-existent path, or other SMB errors.- If "Folder" option is false and a folder path is given, deletion will fail.
Resolutions:
- Verify the exact path exists on the SMB share.
- Ensure the credentials used have delete permissions.
- Enable the "Folder" option if deleting directories.
- Check network connectivity and SMB server availability.
Links and References
- Samba (SMB) Protocol Overview
- n8n Documentation - Creating Custom Nodes
- Node.js fs module (for understanding file operations)