File Manager

Manage files and folders on disk

Overview

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

The Change Permissions operation specifically modifies the Unix permission bits of a specified file or folder, enabling control over access rights (read, write, execute) for user, group, and others.

Practical Examples

  • Adjusting file permissions after uploading files to ensure proper access.
  • Automating batch permission changes on multiple files or folders.
  • Integrating with workflows that require setting executable flags on scripts before execution.

Properties

Name Meaning
Source Path Path of the source file or folder (used in various operations but not required for chmod).
Target Path Path of the file or folder whose permissions will be changed.
Mode Unix permission bits to apply, e.g., 644 (decimal) representing standard read/write permissions.

Output

The output JSON object for the Change Permissions operation includes:

  • operation: The string "chmod" indicating the performed operation.
  • success: A boolean true indicating the operation completed successfully.
  • targetPath: The path of the file or folder whose permissions were changed.
  • mode: The numeric mode value applied to the target path.

No binary data is output by this operation.

Example output JSON snippet:

{
  "operation": "chmod",
  "success": true,
  "targetPath": "/path/to/target",
  "mode": 420
}

(Note: The mode 420 corresponds to octal 0644.)

Dependencies

  • Node.js built-in modules:
    • fs (filesystem operations)
    • path (path manipulations)
    • child_process and zlib are used for other operations but not relevant for chmod.
  • No external services or API keys are required.
  • Requires appropriate filesystem permissions for the user running n8n to change file modes.

Troubleshooting

  • Permission Denied Errors:
    If the node throws errors related to insufficient permissions, ensure that the n8n process has the necessary rights to modify the target file or folder's permissions.

  • Invalid Path Errors:
    Verify that the Target Path exists and is accessible. Non-existent paths will cause errors.

  • Invalid Mode Values:
    The Mode property must be a valid Unix permission bit number. Using incorrect values may lead to unexpected permission settings or errors.

  • Operation Not Supported on Windows:
    Changing Unix-style permissions (chmod) may not behave as expected on Windows systems due to different permission models.

Links and References

Discussion