# Scripting

The Directory Opus scripting interface lets you write scripts using any installed ActiveX-scripting language. This allows scripts to be written in common languages which you may already know. JScript (a relative of JavaScript) and VBScript are built into Windows and usually the easiest choices when it comes to compatibility, help and examples from the Directory Opus support forum, and easy sharing with other users. Other languages like Perlscript and Python can be obtained from third-party providers.

With the scripting interface you can, for example:

* Query the state of Listers, tabs, paths and toolbars
* Obtain lists of files and folders and discover information about them (basic information like name, size, date modified, etc, as well as metadata like EXIF information, MP3 tags, etc)
* Write buttons and hotkeys functions purely from script code without resorting to "Rename" hacks
* Test the state of certain system settings (similar to **@ifset** in a traditional function)
* Build collections of files and run commands (Opus internal commands and external programs) on them
* Display dialogs and popup menus
* Access the clipboard, environment variables and folder aliases
* Extend the list of Opus internal commands
* Add additional file and folder information columns that can be displayed in file displays and infotips
* Automatically trigger scripts based on certain events
* Save and load configuration (Opus provides an editor that you can use to edit your script config)

The scripting interface is present as a series of objects that export methods you can invoke and properties you can query (and sometimes set).

There are three ways to use scripts with Opus.

* [**Rename Scripts**](scripting/rename_scripts) let you write a script within the [Advanced Rename](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/scripting/file_operations/renaming_files/advanced_rename/README.md) dialog that gives complete control over file renaming.&#x20;
* [**Script Functions**](scripting/script_functions) are scripts that are [defined directly in a button, menu or hotkey](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/scripting/customize/creating_your_own_buttons/README.md).\
  \* [**Script Add-ins**](scripting/script_add-ins) are script files that are installed in the Opus _Script Addins_ folder. Whereas Script Functions are user-driven (e.g. they execute when the user clicks a button to specifically run the script), script add-ins are event driven. They provide one or more defined event handlers that Opus will invoke in certain situations, and are also used to implement [custom commands](scripting/example_scripts/adding_a_new_internal_command) and [columns](scripting/example_scripts/adding_a_new_column).

See the [Scripting Reference](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/scripting/scripting/README.md) section for a complete guide to the Opus scripting objects, and the [Example Scripts](scripting/example_scripts) section for some examples of the various types of scripts.

Any errors/warnings or text output from a script (via the **DOpus.Output** function) will be displayed in the _Script Log_ panel (part of the _Utility Panel_). You can choose the type of information to display in the log using the [**Preferences / Miscellaneous / Advanced**](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/scripting/preferences/preferences_categories/miscellaneous/advanced_options.md)**: script\_output\_level** option.

You can also use the [**CLI**](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/scripting/additional_functionality/cli.md) tool to design and test ad-hoc scripts.

More:

[Scripting Reference](https://github.com/Chaoses-Ib/DirectoryOpus/blob/main/Manual/scripting/reference/scripting_reference/README.md)\
[Rename Scripts](scripting/rename_scripts)\
[Script Functions](scripting/script_functions)\
[Script Dialogs](scripting/script_dialogs)\
[Script Add-ins](scripting/script_add-ins)\
[Resources](scripting/resources)\
[Example Scripts](scripting/example_scripts)
