Actions15
Overview
This node, named "File Manager," provides a variety of file and folder management operations on the local disk. It supports common filesystem tasks such as copying, moving, renaming, compressing, extracting, reading, writing, appending, deleting files or folders, changing permissions, listing directory contents, checking existence, retrieving metadata, and searching files by pattern.
Typical use cases include automating file organization workflows, backing up data by copying or compressing files, preparing files for further processing by reading or writing content, cleaning up directories by removing files/folders, and managing permissions programmatically.
For example, you could use this node to:
- Copy a set of files from one folder to another.
- Compress a folder into a tar.gz archive.
- Extract an archive into a target directory.
- Rename or move files as part of a data pipeline.
- Read file contents for processing in subsequent nodes.
- Search for files matching a regex pattern within a directory tree.
Properties
| Name | Meaning |
|---|---|
| Operation | The file operation to perform. Options: Append, Change Permissions, Compress, Copy, Create, Exists, Extract, List, Metadata, Move, Read, Remove, Rename, Search, Write. |
| Source Path | Path of the source file or folder (required for operations like copy, move, rename, compress, extract, remove, create). |
| Destination Path | Target path for copy, move, rename, compress, and extract operations (required for these operations). |
| Recursive | Whether to delete folders recursively (only for Remove operation). Defaults to true. |
| Target Path | Path of the file or folder to operate on (used for read, write, append, list, exists, metadata, chmod operations). |
| Data | Content to write or append to the file (used for Write and Append operations). |
| Encoding | File encoding used when reading, writing, or appending files. Defaults to "utf8". |
| Mode | Unix permission bits (e.g., 644) used for Change Permissions operation. |
| Base Path | Directory to start searching from (used for Search operation). |
| Pattern | Regex pattern to match file paths during search (used for Search operation). |
Output
The output JSON structure varies depending on the selected operation:
Copy, Move, Rename, Compress, Extract, Remove, Create
Outputs success status and includessourcePathand/ordestinationPathfields indicating the involved paths.Read
Outputs the file content underdataand thetargetPath.Write, Append
Outputs thetargetPathconfirming where data was written/appended.Change Permissions (chmod)
Outputs thetargetPathand the appliedmode(permission bits).List
Outputs alistarray containing filenames in the target directory and thetargetPath.Exists
Outputs a booleanexistsindicating if the target path exists, along with thetargetPath.Metadata
Outputs file metadata includingsize,mtime(modification time),atime(access time),isDirectory(boolean),isFile(boolean), and thetargetPath.Search
Outputspathsarray with all matched file paths, plus thebasePathandpatternused.
If an error occurs and "Continue On Fail" is enabled, the output will include an error field describing the issue.
No binary data output is produced by this node; it operates on file system paths and textual/buffered content.
Dependencies
- Requires access to the local filesystem where n8n is running.
- Uses Node.js built-in modules:
fs(filesystem),path,child_process(for spawning tar commands), andzlib(for gzip decompression). - For compress and extract operations, the system must have the
tarcommand-line utility available. - No external API keys or credentials are needed.
Troubleshooting
Common Issues:
- Permission errors when accessing or modifying files/folders due to insufficient OS-level permissions.
- Missing
tarutility on the host system causing compress/extract operations to fail. - Invalid paths or non-existent source files/folders leading to errors.
- Incorrect regex patterns in search operation causing no matches or runtime errors.
- Trying to remove non-empty directories without recursive option enabled.
Error Messages:
"Unknown operation": Indicates an unsupported operation was selected."tar exited with code X": Compression or extraction failed; check thattaris installed and accessible.- Filesystem errors like
ENOENT(file not found),EACCES(permission denied), orEPERM(operation not permitted) indicate issues with path validity or permissions.
Resolutions:
- Ensure n8n has appropriate filesystem permissions.
- Install
taron the host machine for compression/extraction. - Verify all input paths exist and are correct.
- Use valid regex syntax for search patterns.
- Enable recursive deletion when removing directories with contents.