File Manager

Manage files and folders on disk

Overview

This node provides comprehensive file and folder management capabilities on the local disk. It supports a variety of operations such as listing directory contents, reading and writing files, checking existence, changing permissions, copying, moving, compressing, extracting archives, and more.

Common scenarios where this node is beneficial include:

  • Automating file system tasks like backing up files or organizing folders.
  • Reading configuration or data files for further processing in workflows.
  • Managing logs by appending or rotating files.
  • Searching for files matching specific patterns within directories.
  • Preparing files for deployment by compressing or extracting archives.

For example, you could use it to list all files in a directory before processing them, or to read a JSON configuration file and pass its content downstream.

Properties

Name Meaning
Source Path Path of the source file or folder. Used as input path for operations like copy, move, etc.
Target Path Path of the file or folder to operate on. Used for operations like read, write, append, list, exists, metadata, chmod.
(Note: For the "List" operation, only "Target Path" is relevant based on your selection.)

Output

The output JSON structure varies depending on the operation. For the List operation specifically:

  • list: An array of strings representing the names of files and folders contained in the specified target directory.
  • targetPath: The path of the directory that was listed.
  • operation: The string "list".
  • success: A boolean indicating if the operation succeeded (true).

Example output JSON for List operation:

{
  "list": ["file1.txt", "file2.jpg", "subfolder"],
  "targetPath": "/path/to/target",
  "operation": "list",
  "success": true
}

Dependencies

  • This node interacts directly with the local filesystem using Node.js built-in modules (fs, path, child_process, zlib).
  • No external API keys or services are required.
  • The environment where n8n runs must have appropriate filesystem permissions to perform the requested operations.
  • For compression and extraction, the system must have the tar command available.

Troubleshooting

  • Permission errors: If the node fails due to permission denied errors, ensure the n8n process has sufficient rights to access or modify the specified paths.
  • Invalid paths: Errors may occur if the provided paths do not exist or are incorrect. Double-check the paths.
  • Missing tar utility: Compression and extraction rely on the tar command-line tool. Ensure it is installed and accessible in the system PATH.
  • Operation not supported: Providing an unknown operation value will throw an error indicating the operation is unknown.
  • Recursive deletion: When deleting directories, if recursive is false and the directory is not empty, the operation will fail.

Links and References

Discussion