File Manager

Manage files and folders on disk

Overview

This node, named "File Manager," provides a variety of file system operations to manage files and folders on disk. It supports actions such as checking if a file or folder exists, reading from or writing to files, appending data, listing directory contents, changing permissions, copying, moving, compressing, extracting archives, renaming, removing files/folders, creating files/folders, and searching for files matching a pattern.

A common use case is automating file management tasks within workflows, such as verifying the existence of a file before processing it, reading configuration files, backing up directories by compressing them, or cleaning up temporary files after workflow execution.

For example, the "Exists" operation can be used to check if a log file is present before attempting to read it, preventing errors in subsequent steps.

Properties

Name Meaning
Source Path Path of the source file or folder (used in operations like copy, move, rename, compress)
Target Path Path of the file or folder to operate on (used in operations like read, write, append, list, exists, metadata, chmod)

For the "Exists" operation specifically, only the Target Path property is required and relevant.

Output

The output JSON object for the "Exists" operation includes:

  • exists (boolean): Indicates whether the specified target file or folder exists (true) or not (false).
  • targetPath (string): The path that was checked for existence.
  • operation (string): The operation performed, here always "exists".
  • success (boolean): Always true if the operation completed without error.

No binary data is output by this operation.

Example output JSON:

{
  "exists": true,
  "targetPath": "/path/to/target",
  "operation": "exists",
  "success": true
}

Dependencies

  • This node uses Node.js built-in modules: fs (filesystem), path, child_process, and zlib.
  • No external services or APIs are required.
  • No special environment variables or credentials are needed.

Troubleshooting

  • Common issues:

    • Providing an invalid or inaccessible path in the Target Path property may cause errors or always return exists: false.
    • Permission issues on the filesystem might prevent the node from accessing the path, resulting in errors.
  • Error messages:

    • If the path does not exist, the node will not throw an error but will return exists: false.
    • If there is a permission denied error or other filesystem access error, the node will throw an error unless "Continue On Fail" is enabled.
  • Resolution:

    • Ensure the path provided is correct and accessible by the user running n8n.
    • Check filesystem permissions.
    • Use "Continue On Fail" option to handle errors gracefully in workflows.

Links and References

Discussion