# File

## Introduction

The File library in Automate provides actions to automate various file-related operations within workflows. This library enables users to create, copy, delete, and move files seamlessly.

The purpose of the File library is to streamline file management tasks by providing easy-to-use actions for creating, copying, deleting, and moving files.

## What is File?

The File component within Automate allows users to perform file operations directly within their automation workflows. It provides a set of actions to interact with files, making it easier to handle file creation, copying, deletion, and moving.

#### Key Features

* <mark style="color:orange;">**Create**</mark><mark style="color:orange;">:</mark>
  * <mark style="color:orange;">Create a new file at a specified path.</mark>
* <mark style="color:orange;">**Copy**</mark><mark style="color:orange;">:</mark>
  * <mark style="color:orange;">Copy an existing file to another location.</mark>
* <mark style="color:orange;">**Delete**</mark><mark style="color:orange;">:</mark>
  * <mark style="color:orange;">Delete a specified file.</mark>
* <mark style="color:orange;">**Move**</mark><mark style="color:orange;">:</mark>
  * <mark style="color:orange;">Move a file to a different folder.</mark>

## How To Use Action

### Create

<figure><img src="/files/fk6QVvxPzY1Qrt9BlqCF" alt=""><figcaption></figcaption></figure>

**Description:** The **Create** action is used to create a new file at a specified path.

**Usage:**

1. **File Path:**
   * Enter or select the path of the file to be created.
   * <mark style="color:green;">**Example:**</mark><mark style="color:green;">**&#x20;**</mark><mark style="color:green;">**`C:\Program Files\NewFile.docx`**</mark>

### Copy

<figure><img src="/files/00VdCXeCHSdiWhcRt9nT" alt=""><figcaption></figcaption></figure>

**Description:** The **Copy** action is used to make a copy of an existing file.

**Usage:**

1. **Source File:**
   * Select the file to be copied.
2. **Destination Path:**
   * <mark style="color:green;">Select or enter the path where the copied file will be placed.</mark>
   * <mark style="color:green;">Check "Overwrite existing files" if needed.</mark>
   * <mark style="color:green;">Specify the desired file size (optional).</mark>

### Delete

<figure><img src="/files/qoZ9p0pdZF6G27p7BxWf" alt=""><figcaption></figcaption></figure>

**Description:** The **Delete** action is used to delete a specified file.

**Usage:**

1. **File Path:**
   * <mark style="color:green;">Select the path of the file to be deleted.</mark>

### Move

<figure><img src="/files/U7OkXt3l7qPEpxXErdva" alt=""><figcaption></figcaption></figure>

**Description:** The **Move** action is used to move a file to a different folder.

**Usage:**

1. **Source File Path:**
   * <mark style="color:green;">Select the file to be moved.</mark>
2. **Destination Folder Path:**
   * <mark style="color:green;">Select or enter the path of the destination folder.</mark>

### **Get File Properties**

#### **Description and Purpose**

The **Get File Properties** action allows Autom Mate users to retrieve detailed metadata and properties of a specific file stored in **Mate Drive**. This action is useful for inspecting file attributes such as name, size, MIME type, permissions, and modification dates, which can be used for conditional logic, logging, or file validation within a workflow.

By providing the file path and assigning the output to a variable, users can make file-aware decisions across the automation process.

***

#### **Usage Instructions**

{% stepper %}
{% step %}
**Provide File Path**

**File Path (Required):**\
Enter the full path of the file stored in Mate Drive for which properties should be retrieved.\
Example:

```
mate:/Release 450 Notes.docx
```

{% hint style="info" %}
Use file paths generated by other actions (e.g., Save to MateDrive) to dynamically fetch file details during runtime.
{% endhint %}
{% endstep %}

{% step %}
**Assign Output Variable**

**Assign file properties to variable (Required):**\
Select an object-type variable (e.g., `resp`) to store the file properties returned by the action.

{% hint style="info" %}
You can use the output variable in downstream actions like condition checks, messages, or audit logs.
{% endhint %}
{% endstep %}

{% step %}
**Execute and Review**

Run the action. After execution, the output variable will contain the file’s properties such as size, format, creation date, last modified date, permissions, and more.
{% endstep %}
{% endstepper %}

***

#### **Inputs**

<table><thead><tr><th width="234">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>File Path</strong></td><td>The full Mate Drive file path to inspect (e.g., <code>mate:/example.docx</code>).</td></tr></tbody></table>

***

#### **Outputs**

<table><thead><tr><th width="234">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>Output Variable</strong> (<code>object</code>)</td><td>Contains all properties of the given file such as name, path, MIME type, size, permissions, and timestamps.</td></tr></tbody></table>

***

#### **Example Output**

```json
{
  "CreatedDate": "2025-06-03 13:04:50.2941845 +0300 +03",
  "Extension": ".docx",
  "LastModified": "2025-06-03 13:04:50.2947408 +0300 +03",
  "Name": "Release 450 Notes.docx",
  "Permissions": "-rw-rw-rw-",
  "Size": 27765
}
```

### **Rename**

#### **Description and Purpose**

The **File - Rename** action allows Autom Mate users to rename an existing file stored in **MateDrive**. This action is useful for dynamically changing file names during workflows, such as appending dates, adding version numbers, or organizing files based on their content or context.

By providing the source file path and the new file name, users can automate file renaming tasks without manual intervention, ensuring efficient file management.

***

#### **Usage Instructions**

{% stepper %}
{% step %}
**Provide File Path**

**File Path (Required):**\
Enter the full path of the file that you want to rename.\
Example:

```
mate:/newFileName.png
```

This is the path of the existing file in Mate Drive that will be renamed.
{% endstep %}

{% step %}
**Specify New File Name**

**New File Name (Required):**\
Enter the new name you want to assign to the file.\
Example:

```
newFileName
```

Ensure that the new file name includes the proper extension (e.g., `.png`, `.txt`, `.pdf`) to maintain the file's correct format.
{% endstep %}

{% step %}
**Execute and Review**

Run the action. After execution, the file at the provided path will be renamed to the new name specified. The change will be reflected in the Mate Drive file system.
{% endstep %}
{% endstepper %}

***

#### **Inputs**

<table><thead><tr><th width="234">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>File Path</strong></td><td>The full path of the existing file to rename (e.g., <code>mate:/oldFileName.png</code>).</td></tr><tr><td><strong>New File Name</strong></td><td>The new name to assign to the file (e.g., <code>newFileName</code>).</td></tr></tbody></table>

***

#### **Outputs**

<table><thead><tr><th width="234">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>File Path</strong></td><td>The path of the renamed file in Mate Drive (e.g., <code>mate:/newFileName.png</code>).</td></tr></tbody></table>

***

#### **Example**

* **File Path**:

```
mate:/oldFileName.png
```

* **New File Name**:

```
newFileName.png
```

* **Output**:\
  The file `mate:/oldFileName.png` will be renamed to `mate:/newFileName.png` after the action is executed.

### **Unzip**

#### **Description and Purpose**

The **File - Unzip** action allows Autom Mate users to extract the contents of a ZIP file stored in **Mate Drive**. This action is useful for automating the extraction of compressed files, enabling easy access to the files inside the archive. Users can choose to extract the contents to the same path or specify a different destination folder.

By providing the path of the ZIP file and the desired extraction destination, users can streamline file management and processing tasks.

***

#### **Usage Instructions**

{% stepper %}
{% step %}
**Provide Zip File Path**

**Zip File Path (Required):**\
Enter the full path of the ZIP file you want to extract.\
Example:

```
mate:/archive (2).zip
```

This is the path to the ZIP file stored in Mate Drive that will be unzipped.
{% endstep %}

{% step %}
**Specify Destination Folder**

**Destination**:\
Choose where you want to extract the files.

* **Extract to same path**: Extracts the contents into the same directory as the ZIP file.
* **Extract to given path (Required)**: Specify a different folder where the files will be extracted.\
  Example:

  ```
  mate:/unzip
  ```

{% hint style="info" %}
Ensure the destination path is correct to avoid file overwriting or errors.
{% endhint %}
{% endstep %}

{% step %}
**Overwrite Existing Folder**

**Overwrite an existing folder**:\
Enable this option if you want to replace the contents of an existing folder with the extracted files.

{% hint style="danger" %}
Enabling this option will remove any existing files in the destination folder and replace them with the extracted files.
{% endhint %}
{% endstep %}

{% step %}
**Assign Folder Path to Variable**

**Assign folder path to variable (Required):**\
Select a string-type variable (e.g., `NewFilePath`) to store the full path of the destination folder where the files were extracted.\
Example:

```
NewFilePath
```

This allows referencing the extracted folder's location in subsequent workflow steps.
{% endstep %}

{% step %}
**Execute and Review**

Run the action. After execution, the contents of the ZIP file will be extracted to the specified folder, and the folder path will be stored in the chosen output variable.
{% endstep %}
{% endstepper %}

***

#### **Inputs**

<table><thead><tr><th width="280">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>Zip File Path</strong></td><td>The path of the ZIP file to be extracted (e.g., <code>mate:/archive (2).zip</code>).</td></tr><tr><td><strong>Destination</strong></td><td>The folder path where the ZIP file should be extracted (either the same path or a new one).</td></tr><tr><td><strong>Overwrite Existing Folder</strong></td><td>Enable to overwrite existing folder contents with the extracted files.</td></tr><tr><td><strong>Assign Folder Path to Variable</strong></td><td>Select a string variable (e.g., <code>NewFilePath</code>) to store the destination path.</td></tr></tbody></table>

***

#### **Outputs**

<table><thead><tr><th width="280">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>New File Path</strong></td><td>The path of the folder where the files were extracted (e.g., <code>mate:/unzip</code>).</td></tr></tbody></table>

***

#### **Example**

* **Zip File Path**:

```
ymate:/archive (2).zip
```

* **Destination**:

```
mate:/unzip
```

* **Output Variable (`NewFilePath`)**:\
  The files from the archive will be extracted to the folder `mate:/unzip`, and the output variable will store this path.

### **Zip**

#### **Description and Purpose**

The **File - Zip** action allows Autom Mate users to compress files and directories into a ZIP archive within **Mate Drive**. This action is useful for organizing multiple files or folders into a single compressed file for easier storage, transfer, or backup. Users can specify the file to be zipped and define the destination and zip file name.

***

#### **Usage Instructions**

{% stepper %}
{% step %}
**Provide File Path**

**File Path (Required):**\
Enter the full path of the file or directory to be compressed into a ZIP archive.\
Example:

```
mate:/test.txt
```

This is the path of the file or folder to be zipped.
{% endstep %}

{% step %}
**Specify Zip Name**

**Zip Name:**\
Enter the desired name for the resulting ZIP file.\
Example:

```
ZipTest
```

By default, if no name is provided, the folder name will be used for the ZIP archive. Make sure the name ends with `.zip` to indicate it's a compressed file.
{% endstep %}

{% step %}
Choose Destination

**Destination**:\
Select where you want to save the ZIP file.

* **Extract to same path**: The ZIP file will be saved in the same directory as the original file or folder.
* **Extract to given path**: Specify a different folder to store the ZIP file.\
  Example:

  ```
  mate:/archives
  ```

{% hint style="info" %}
Make sure the destination path is correct and accessible.
{% endhint %}
{% endstep %}

{% step %}
**Overwrite Existing Folder**

**Overwrite an existing folder**:\
Enable this option if you want to replace any existing file or folder with the same name in the destination.

{% hint style="danger" %}
Enabling this option will overwrite the existing ZIP file or folder in the destination with the new one.
{% endhint %}
{% endstep %}

{% step %}
**Assign File Path to Variable**

**Assign file path to variable (Required):**\
Select a string-type variable (e.g., `ziptest`) to store the full path of the newly created ZIP file.\
Example:

```
ziptest
```

This allows you to reference the created ZIP file’s location in subsequent actions.
{% endstep %}

{% step %}
**Execute and Review**

Run the action. After execution, the specified file(s) or folder will be compressed into a ZIP file, and the path of the ZIP file will be stored in the output variable.
{% endstep %}
{% endstepper %}

***

#### **Inputs**

<table><thead><tr><th width="240">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>File Path</strong></td><td>The path of the file or folder to compress into a ZIP archive.</td></tr><tr><td><strong>Zip Name</strong></td><td>The name to assign to the resulting ZIP file.</td></tr><tr><td><strong>Destination</strong></td><td>The folder path where the ZIP file should be saved.</td></tr><tr><td><strong>Overwrite Existing Folder</strong></td><td>Enable to overwrite an existing file with the same name.</td></tr><tr><td><strong>Assign File Path to Variable</strong></td><td>Select a string variable to store the file path of the created ZIP archive.</td></tr></tbody></table>

***

#### **Outputs**

<table><thead><tr><th width="240">Field</th><th>Description</th></tr></thead><tbody><tr><td><strong>New File Path</strong></td><td>The path of the created ZIP file (e.g.,<code>mate:/archives/ZipTest.zip</code>).</td></tr></tbody></table>

***

#### **Example**

* **File Path**:

```
mate:/test.txt
```

* **Zip Name**:

```
ZipTest
```

* **Destination**:

```
mate:/archives
```

* **Output Variable (`ziptest`)**:\
  The file `mate:/test.txt` will be compressed into the ZIP file `mate:/archives/ZipTest.zip`, and the output variable `ziptest` will store this path.

***

## Additional Tips

### [**Use Cases**](/userguide/use-cases.md)

### [FAQ](/userguide/faq.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.autommate.com/userguide/libraries/transform/file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
