# Find File Path

This is a pre-built Action located under the **@Generic Element**. The functionality of this Action in Avo Assure is to find a file in a given folder location. The retrieved file path is stored in a dynamic variable.

## **Syntax**

**Input Value**: `<file name>;<folder path>`&#x20;

{% hint style="info" %}
**Supported Input Formats:**&#x20;

* **Text**: A fixed value that you manually provide. &#x20;
* **Static Value**: Provide a value from a data parameter (for example, from an Excel sheet or Data Table).  &#x20;
* **Dynamic Variable**: Value retrieved from a previously stored output variable or dynamically created variable.&#x20;
  {% endhint %}

| Argument                             | Description                                                                                                                                                                                                                                                |
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p>\<file name></p><p>(Required)</p> | <p>Provide the file name to search for a specific file.</p><p><strong>Note</strong>: To find the file path of the most recently downloaded file, use the <strong>LATEST</strong> or <strong>latest</strong> or <strong>Latest</strong> word parameter.</p> |
| <p>\<folder path><br>(Required)</p>  | Provide the folder path where the action searches for the specified file.                                                                                                                                                                                  |

**Output Value**: `<Dynamic Variable>;<Dynamic Variable>(Optional)`

| Argument                                 | Description                                                       |
| ---------------------------------------- | ----------------------------------------------------------------- |
| <p>\<Dynamic Variable><br>(Required)</p> | This dynamic variable holds the file path.                        |
| <p>\<Dynamic Variable><br>(Optional)</p> | This dynamic variable stores the status as **True** or **False**. |

### Example 1: Searching for a File Path by File Name and File Path

In this example, we explain how to search for a file inside a folder.

* **Action**: Find File Path
* **Input Value**: New Orders;C:\Users\john\Downloads
  * The first argument (**New Orders**) specifies the name of the file to search for.
  * The second argument (**C:\Users\john\Downloads**) specifies the root folder path where the search begins, including all subfolders.
* **Output Value**: {File path}
  * The file path (e.g., C:/Users/john/Downloads/Wearhouse/New Orders.xlsx) is stored in this **{File Path}** dynamic variable.
  * If the second output variable is defined, the action returns the status as **True** or **False**:
    * **True**: If the file exists in the given folder or any of its subfolders.
    * **False**: If the file is not found.
* **Logical Explanation**: The **Find File Path** action takes the value from the **Input Value** column (**New Orders;C:\Users\john\Downloads**) and searches for the specified file within the given folder to identify the most recently downloaded file. The action stores the full file path (**C:/Users/john/Downloads/Wearhouse/New Orders.xlsx**) in the **{File path}** variable.

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FwNNVNAfCcMWeSPy6HE3p%2Fimage.png?alt=media&#x26;token=43ac5fd9-ac83-46d2-84ba-0de622be8d1b" alt=""><figcaption></figcaption></figure>

### Example 2: Searching the File Path for the Latest Downloaded File

In this example, we explain how to retrieve the most recently downloaded file from a specified folder.

**Action**: Find File Path

**Input Value**: latest;C:\Users\john\Documents\Datafile\_files

* The first argument (**latest**) instructs the system to identify the most recently downloaded file in the specified folder.
* The second argument (**C:\Users\john\Documents\Datafile\_files**) specifies the folder path where the search is performed.

**Output Value**: {File path}

* The file path (e.g., C:/Users/john/Documents/Datafile\_files/New Data.xlsx) is stored in this **{File Path}** dynamic variable.
* If a second output variable is provided, the action returns the status as True or False:
  * **True**: If the latest file is successfully identified in the given folder.
  * **False**: If the latest file is not found.
* **Logical Explanation**: The **Find File Path** action takes the value from the **Input Value** column (**latest;C:\Users\john\Documents\Datafile\_files**) and scans the specified folder to identify the most recently downloaded file. Once found, the action stores the full file path (**C:/Users/john/Documents/Datafile\_files/New Data.xlsx**) in the **{File path}** variable.

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2F2X7Mu8pBjP4DAYNRjYSI%2Fimage.png?alt=media&#x26;token=4b92a288-70bc-4c4b-a9ac-fa219a9f61cd" alt=""><figcaption></figcaption></figure>

### Example 3: Searching File Path When the Same File Exists in Different Locations

In this example, we explain how the system behaves when the same file exists in different folder locations.

**Action**: Find File Path

**Input Value**: Employee Data;C:\Users\john\Downloads

* The first argument (**Employee Data**) specifies the file name to search
* The second argument (**C:\Users\john\Downloads**) specifies the system which folder to start searching from. The system searches across folders under the specified path.

**Output Value**: {File path}

{% hint style="info" %}
**Note**: If the same file exists in multiple subfolders within the specified parent folder, the system returns all matching file paths in array format.
{% endhint %}

* The file path (e.g., **\['C:/Users/john/Downloads/Employee Data.docx', 'C:/Users/john/Downloads/Data/Employee Data.docx', 'C:/Users/john/Downloads/EmpData/Employee Data.docx']**) is stored in this **{File Path}** dynamic variable.
* If a second output variable is provided, the action returns the status as True or False:
  * **True**: If the file is successfully identified in the given folder or subfolder.
  * **False**: If the file is not found.
* **Logical Explanation**: The **Find File Path** action takes the value from the **Input Value** column (**Employee Data;C:\Users\john\Downloads**) and scans the specified folder and its subfolders to search for the file named **Employee Data**. If the same file exists in multiple folders within the given location, the action collects all matching file paths and stores them in the **{File path}** variable in array format (**\['C:/Users/john/Downloads/Employee Data.docx', 'C:/Users/john/Downloads/Data/Employee Data.docx', 'C:/Users/john/Downloads/EmpData/Employee Data.docx']**).

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FXkFOmsd237nJptVl8UEk%2Fimage.png?alt=media&#x26;token=d158321d-c7ea-4908-bcef-eb9e4f56fba3" alt=""><figcaption></figcaption></figure>
