File Manager

Manage files and folders on disk

Overview

This node provides file and folder management operations on the local disk. It supports a variety of common filesystem tasks such as compressing files or folders into archives, copying, moving, renaming, creating, deleting, reading, writing, appending to files, changing permissions, listing directory contents, checking existence, retrieving metadata, extracting archives, and searching for files matching patterns.

The Compress operation specifically creates a compressed archive (tar.gz) from a specified source file or folder and saves it to a target destination path. This is useful for packaging files or directories for backup, transfer, or storage in a compressed format.

Practical examples:

  • Compressing a project folder before uploading it to cloud storage.
  • Archiving log files daily into compressed archives to save space.
  • Packaging multiple files into one compressed archive for easier distribution.

Properties

Name Meaning
Source Path Path of the source file or folder to be compressed.
Destination Path Target path where the compressed archive (tar.gz) will be saved.

Output

The output JSON contains the following fields after successful compression:

  • operation: The string "compress" indicating the performed operation.
  • success: Boolean true indicating the operation succeeded.
  • sourcePath: The original source path that was compressed.
  • destinationPath: The path where the compressed archive was created.

No binary data is output by this node; it only returns metadata about the operation.

Dependencies

  • Requires access to the local filesystem with appropriate read/write permissions.
  • Uses the system's tar command-line utility to perform compression (tar -czf).
  • Node.js built-in modules: fs (filesystem), path, child_process (to spawn tar), and zlib.

No external API keys or credentials are needed.

Troubleshooting

  • Common issues:

    • The tar command may not be available or accessible on the system PATH, causing the compression to fail.
    • Insufficient filesystem permissions to read the source or write to the destination path.
    • Specifying invalid or non-existent source paths.
    • Destination path pointing to a location without write permission.
  • Error messages:

    • tar exited with code X: Indicates the tar process failed with exit code X. Check if the source path exists and is accessible, and verify the destination path is writable.
    • Filesystem errors like "ENOENT" (no such file or directory) or "EACCES" (permission denied) can occur if paths are incorrect or permissions insufficient.
  • Resolutions:

    • Ensure the tar utility is installed and available in the environment where n8n runs.
    • Verify all paths exist and have correct permissions.
    • Use absolute paths to avoid ambiguity.
    • Run n8n with sufficient privileges to access the required files and folders.

Links and References

Discussion