Adding dopus commands to rename script

How are Dopus commands added to a rename script please. For instance in a normal button script this works

var cmd = clickData.func.command;
var command = "Delete";

but in a rename script it produces this error

There's no clickData in a rename script, so you aren't given a pre-made Command object. If you want a Command object you have to create a new one via DOpus.Create.Command.

You'll also need to either specify the path as part of the command you're running, or use Command.AddFiles(item) to tell the object which file(s) to act on.

Be careful with commands in rename scripts, they already get executed on preview (and any refresh).

function OnGetNewName(getNewNameData)
var cmd = DOpus.Create.Command;
cmd.RunCommand('FileType NEW=.txt');
1 Like

hmmm, does not work (almost works), trying to convert a rename button to a rename preset

function OnGetNewName(getNewNameData)
var cmd = DOpus.Create.Command;
cmd.RunCommand('Rename TYPE=files REGEXP PATTERN ".(.+)(\..*)#{dlgstring|Enter Number of Characters to Remove}" TO "\1\2" AUTORENAME');


  • Do you really want to enter a number for every single file?
  • # only works this way in the command, not in the dialog.
  • How about a macro (F2)?

if multiple files selected then remove n letters from each

command works fine as button, not sure what is meant here

If it can be saved as a rename preset.

The buttons are from here RegExp basics: Removing characters from start/end of names - Rename Presets - Directory Opus Resource Centre (
I am currently tidying my rename presets after discovering 'groups' after reading one of your fine posts, and these buttons cannot be put into a group, so I was trying to convert them to a preset. But that is proving more difficult than anticipated and another lesson learnt - no dialogs in rename scripts but normal commands/button scripts can have dialogs and also rename.

You could use a command like this (remove ADVANCED if you don't want the preview )...

Rename MACRO L0-{dlgstring|Enter Number of Characters to Remove} ADVANCED 

... or a preset you can select in the Advanced Renamer:

Save 45821.orp to

%appdata%\GPSoftware\Directory Opus\Rename Presets

Really depends on how/where you want to enter the number and if you need the preview.