> 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/scripting/example_scripts/example_rename_script.md).

# Example Rename Script

This is an example of a [rename script](/directory-opus/manual/scripting/rename_scripts.md) that adds an image file's resolution to its filename.

You would use this script through the [**Advanced Rename**](/directory-opus/manual/file_operations/renaming_files/advanced_rename.md) dialog (turn on the **Script mode** option to display the script editor). You could also [embed the script in a button](/directory-opus/manual/customize/creating_your_own_buttons/embedding_rename_scripts.md).

```
' Set the script type to VBScript to use this script
Option Explicit

' Main Rename entry point.
' The method is passed a GetNewNameData object for each file.
Function OnGetNewName ( ByRef GetNewNameData )
    Dim item, meta

    ' Get the provided Item object from the GetNewNameData object's item property.
    Set item = GetNewNameData.item

    ' Request its metadata. This will return a Metadataobject.
    Set meta = item.metadata

    ' If the primary type of the meta data is "image" then we know it's an image file.
    If meta = "image" Then
        ' Build and return the new name
        ' This is made up of
        ' - the "name stem" (the original filename minus the file extension)
        ' - the image width and height, obtained from the ImageMeta object (which comes from the Metadata.image property)
        ' - the original filename extension.
        OnGetNewName = item.name_stem & " (" & meta.image.picwidth & "x" & meta.image.picheight & ")" & item.ext
    Else
        ' The item wasn't an image, so return True to skip it.
        OnGetNewName = True
    End If
End Function
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/scripting/example_scripts/example_rename_script.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.
