> For the complete documentation index, see [llms.txt](https://chaoses-ib.gitbook.io/directory-opus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/scripting_reference/scripting_events/ongetnewname.md).

# OnGetNewName

The **OnGetNewName** event is one of the three alternate entry points for [rename scripts](/directory-opus/manual/scripting/rename_scripts.md). The other two events - **Rename\_GetNewName** and **Rename\_GetNewName2**, are deprecated should only be used for backwards compatibility with Opus 10.

| **Method Name:**   | OnGetNewName                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Argument Type:** | [**GetNewNameData**](/directory-opus/manual/reference/scripting_reference/scripting_objects/getnewnamedata.md)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| **Return Type:**   | *bool* or *string*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| **Description:**   | <p>When using a rename script, the <strong>OnGetNewName</strong> event is called for every selected file and folder, giving the script a chance to modify the name.<br>The <strong>GetNewNameData.item</strong> property identifies the item being renamed. You can access the item's metadata and other information using the various <a href="/directory-opus/manual/reference/scripting_reference/scripting_objects/item.md"><strong>Item</strong></a> properties.<br>The <strong>oldname</strong> property returns the "old name" pattern as entered by the user in the <a href="/directory-opus/manual/file_operations/renaming_files/advanced_rename.md">rename dialog</a>. The <strong>newname</strong> property returns the proposed new name of the item. This represents the result of all the other non-scripted options in the rename dialog (capitalization, automatic numbering, etc).</p><p>You can return two different types from this event:</p><ul><li><em>bool</em>: If you return <strong>True</strong>, the item will not be renamed. If you return <strong>False</strong> (this is the default) the item will be renamed to the proposed new name (the <strong>newname</strong> property).</li><li><em>string</em>: You can return a <em>string</em> to specify a new name for the item.</li></ul> |
