# OnBeforeFolderChange

The **OnBeforeFolderChange** event can be implemented by a [script add-in](https://chaoses-ib.gitbook.io/directory-opus/manual/scripting/script_add-ins) to receive notification before a new folder is read in a tab. Use the **OnAfterFolderChange** event if you want notification *after* a folder has been read.

| **Method Name:**   | OnBeforeFolderChange                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Argument Type:** | [**BeforeFolderChangeData**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_objects/beforefolderchangedata)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| **Return Type:**   | *bool* or *string*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| **Description:**   | <p>The <strong>BeforeFolderChangeData.tab</strong> property identifies the tab, and the <strong>path</strong> property identifies the folder about to be read. The <strong>initial</strong> property indicates if this is the first folder read into this tab - if <strong>True</strong>, it means the tab was previously empty or newly opened.</p><p>You can return two different types from this event:</p><ul><li><em>bool</em>: If you return <strong>True</strong>, the folder read will be blocked and the tab will be unchanged. If you return <strong>False</strong> the read will be allowed to continue (this is the default).</li><li><em>string</em>: You can return a <em>string</em> (or a <a href="../scripting_objects/path"><strong>Path</strong></a> object) to change the folder path to be read.</li></ul> |


---

# 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://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_events/onbeforefolderchange.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.
