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, checking existence, listing directory contents, changing permissions, copying, moving, compressing, extracting archives, renaming, removing files or folders, creating files or directories, 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 folders exist before proceeding.
  • 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 (required for many ops).
Target Path Path of the file or folder to operate on (used in read, write, append, list, exists, metadata, chmod operations).
Encoding File encoding used when reading, writing, or appending files (default is "utf8").
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 copy, move, rename, compress, and extract operations.
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).
Mode Unix permission bits (e.g., 644) used in change permissions operation.
Base Path Directory to start searching from (used in search operation).
Pattern Regex pattern to match file paths during search operation.

Output

The output JSON structure varies depending on the operation performed:

  • read: Outputs data containing the file content as a string, and targetPath.
  • write, append: Outputs targetPath.
  • list: Outputs list, an array of filenames in the target directory, and targetPath.
  • exists: Outputs exists (boolean indicating presence), and targetPath.
  • metadata: Outputs file metadata including size (bytes), mtime (modification time), atime (access time), isDirectory (boolean), isFile (boolean), and targetPath.
  • chmod: Outputs targetPath and the applied mode.
  • copy, move, rename, compress, extract, remove, create: Outputs success (true), operation name, and relevant paths (sourcePath, destinationPath).
  • search: Outputs paths (array of matched file paths), basePath, and pattern.

If an operation fails and "Continue On Fail" is enabled, the output includes an error field describing the failure.

No binary data output is produced by this node.

Dependencies

  • Requires access to the local filesystem where n8n is running.
  • Uses Node.js built-in modules: fs (filesystem), path, child_process (for tar commands), and zlib (for gzip decompression).
  • No external API keys or credentials are needed.
  • For compress and extract operations, the system must have the tar command available in the environment.

Troubleshooting

  • Common issues:

    • Permission errors when accessing or modifying files/folders due to insufficient OS-level permissions.
    • Missing or incorrect paths causing "file not found" errors.
    • Absence of the tar utility on the host system will cause compress/extract operations to fail.
    • Invalid regex patterns in search operation may throw syntax errors.
    • Trying to remove non-empty directories without enabling recursive deletion will fail.
  • Error messages:

    • "Unknown operation": Indicates an unsupported operation was selected.
    • "tar exited with code X": Compression or extraction failed; ensure tar is installed and accessible.
    • Filesystem errors like "ENOENT" (no such file or directory) or "EACCES" (permission denied) indicate path or permission problems.
  • Resolutions:

    • Verify file and folder paths are correct and accessible.
    • Ensure n8n has appropriate OS permissions.
    • Install tar on the system for archive operations.
    • Use valid regex patterns.
    • Enable recursive option when deleting folders with contents.

Links and References

Discussion