File Manager

Manage files and folders on disk

Overview

This node, named "File Manager," provides a comprehensive set of file and folder management operations on the local disk. It allows users to perform common filesystem tasks such as reading, writing, appending files, listing directory contents, checking existence, retrieving metadata, changing permissions, copying, moving, renaming, compressing, extracting, creating, removing files or folders, and searching for files matching a pattern.

Typical use cases include automating file manipulations in workflows, such as:

  • Reading configuration files or logs.
  • Writing or appending data to files.
  • Managing backups by compressing or extracting archives.
  • Organizing files by moving or renaming them.
  • Checking if certain files or directories exist before proceeding.
  • Retrieving file metadata for auditing or processing decisions.
  • Searching for files matching specific patterns recursively.

For example, you could use this node to read a JSON config file, modify it, and write it back; or to compress a folder before uploading it elsewhere.

Properties

Name Meaning
Source Path Path of the source file or folder involved in the operation.
Target Path Path of the file or folder to operate on (used in operations like read, write, append, list, exists, metadata, chmod).
Operation The action to perform. Options include: Append, Change Permissions, Compress, Copy, Create, Exists, Extract, List, Metadata, Move, Read, Remove, Rename, Search, Write.
Destination Path Target path for operations that move, copy, rename, compress, or extract files/folders.
Recursive Whether to delete folders recursively (used in remove operation).
Data Content to write or append to a file (used in write and append operations).
Encoding File encoding used when reading, writing, or appending files (default is utf8).
Mode Unix permission bits for changing file/folder permissions (e.g., 644) (used in chmod).
Base Path Directory to start searching from (used in search operation).
Pattern Regex pattern to match file paths during search.

Note: For this summary, only the properties relevant to the "Metadata" operation are considered, which requires the Target Path property.

Output

The output JSON object for the "Metadata" operation includes the following fields:

  • size: Size of the target file or folder in bytes.
  • mtime: Last modification time (Date object).
  • atime: Last access time (Date object).
  • isDirectory: Boolean indicating if the target path is a directory.
  • isFile: Boolean indicating if the target path is a regular file.
  • targetPath: The path of the file or folder for which metadata was retrieved.
  • operation: The string "metadata".
  • success: Boolean true indicating the operation succeeded.

No binary data is output by this operation.

Dependencies

  • Node.js built-in modules:
    • fs (filesystem operations)
    • path (path utilities)
    • child_process (for some operations, not used in metadata)
    • zlib (for compression/extraction, not used in metadata)

No external services or API keys are required. The node operates on the local filesystem where n8n is running.

Troubleshooting

  • Common issues:

    • Invalid or inaccessible target path: If the specified path does not exist or the node process lacks permissions, the operation will fail.
    • Permission errors: Insufficient rights to read metadata of certain files or directories.
    • Incorrect path format: Paths must be valid and accessible on the host system.
  • Error messages:

    • Errors thrown by the underlying filesystem calls (e.g., lstat) will be reported. These typically indicate missing files, permission denied, or invalid paths.
    • The node throws an error if an unknown operation is specified.
  • Resolution tips:

    • Verify the target path exists and is accessible by the user running n8n.
    • Check file and folder permissions.
    • Use absolute paths to avoid ambiguity.
    • Enable "Continue On Fail" in the node settings to handle errors gracefully within workflows.

Links and References

Discussion