# OnGetNewName

The **OnGetNewName** event is one of the three alternate entry points for [rename scripts](../../../scripting/rename_scripts). 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**](../scripting_objects/getnewnamedata)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **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="../scripting_objects/item"><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="../../../file_operations/renaming_files/advanced_rename">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> |
