# Embedding Rename Scripts

[Rename scripts](https://chaoses-ib.gitbook.io/directory-opus/manual/file_operations/renaming_files/advanced_rename/rename_scripts) can be embedded directly in a button or hotkey, which lets you rename files using a script without having to display the [**Advanced Rename**](https://chaoses-ib.gitbook.io/directory-opus/manual/file_operations/renaming_files/advanced_rename) dialog first.

![](https://3597805814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3XSZSwWow0fDf6fQJobd%2Fuploads%2Fgit-blob-b478ffe94db0916aca8339245a7b51c0597ff310%2Frename_embed.png?alt=media)

This image depicts an example of an embedded rename script. The first line of such a button must call the [**Rename**](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/command_reference/internal_commands/rename) command. This command actually invokes the Rename function - and you can use any of the arguments for the **Rename** command to perform "pre-processing" before the script is invoked. For example, you could use the command **Rename CASE=allwords** to capitalize words in the filename first, before the script is invoked. In the above screenshot the **Rename** command will not actually modify the filename itself - it will be passed through verbatim to the script.

Below the **Rename** command, the **@script** [command modifier](https://chaoses-ib.gitbook.io/directory-opus/manual/reference/command_reference/command_modifier_reference) is used to introduce the script. This tells Opus which language the script is written in - **vbscript** is shown in the above screenshot, but you can specify **jscript** to use JavaScript, and other languages are also supported if you have them installed.

Any text in the function definition below the **@script** line defines the script itself. See the [Rename Scripts](https://chaoses-ib.gitbook.io/directory-opus/manual/scripting/rename_scripts) page for more information on writing rename scripts.


---

# 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/customize/creating_your_own_buttons/embedding_rename_scripts.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.
