Custom Button Examples

See Raw Commands in the manual
for descriptions of the internal
commands and their arguments.

Pre-made buttons are provided for doing all the things you'd expect like switching to a thumbnails view or jumping to My Computer. You'll find buttons for doing basic file copying and renaming on the default toolbar and there are more in the customize dialog, ready to be dragged to your toolbar, as we saw already. But what happens when those 180 pre-made buttons aren't enough and you want to do something slightly different? You roll your own!

See External Command Control Codes,
and John Zeman's tutorial document,
to learn about the codes used to pass
arguments to other programs.

The drop-down menus in the Advanced Button Editor help you by providing context-sensitive lists that show the available commands and currently applicable arguments. You never have to go to the manual just because you've forgotten an argument's name.

This section should give you a taste for what can be done using custom buttons. These are all based on real-world examples, taken from my own configuration.

Drop-down menus help when making custom buttons.
Create folder from clipboard
 

Let's start with something simple. By default, the CreateFolder command pops open a dialog where you give the name of the folder you want to create. (It can also create multiple folders at once, including hierarchies.) If you add the FromClipboard argument to the command then it won't open a dialog anymore; instead it will create a folder automatically using whatever is in the clipboard for its name.

CreateFolder FROMCLIPBOARD

The Opus "three-button" is ideal for putting several versions of a given command on the toolbar without using any extra space. Left-click the button for one function, middle-click for another and right-click for a third variant. You can also create pop-up menus and hybrid button-menus which consist of both a button and, next to it, a small arrow which opens a pop-up menu.

You could assign the Create Folder From Clipboard function to the right-click action of the Create Folder button on the default toolbar, enabling you to have both the normal and your customized functionality available at the same time on the same button.

Rename in one click
 

If you find yourself frequently doing the same rename operation then you can make a button which does it in a single click. Find and replace, wildcards and regular expressions are all supported for renaming, both in the Rename dialog and in one-click button commands.

Convert underscores to spaces:

Rename PATTERN="_" TO=" " FINDREP

@NODESELECT

Capitalise the first letter of every word:

Rename CASE=allwords

@NODESELECT

The @NODESELECT line tells Opus to leave the files selected after the command has run. This is useful when you know you'll often want to run another function on the same files.

I've got these commands on the right-click and middle-click actions of my Rename button for quick access to either or both of them.

Perform common renames in one click.
Rename with the date and time
 

You can insert the current date and time into the names used when creating and renaming files and folders. This is great for quickly timestamping a backup or making a temporary folder with a unique name via a single click.

Create Dated Folder:

CreateFolder NAME="{date|yyyy-MM-dd} {time|HH-mm-ss}"

Time-Prefix Selected Names:

Select sorted_* DESELECT

Rename PATTERN=* TO=sorted_{time|HHmmss}_*

I use this button on directories where files are created by other programs and the same filenames are used for each run (e.g. Frame01.jpg). I can quickly do a select all and then click this button without further thought. The first line ensures that files whose names already start with "sorted_" are not renamed a second time.

Date-Suffix Selected Names:

Rename PATTERN="*" TO="* - {date|yyyy-MM-dd} {time|HH-mm-ss}" AUTORENAME TYPE=dirs

Rename PATTERN="^(.*)(\.[^\.]+)$" TO="\1 - {date|yyyy-MM-dd} {time|HH-mm-ss}\2" REGEXP AUTORENAME TYPE=files

The first rename only acts on directories while the second only acts on files. While the first uses a simple wildcard, the second uses a more complex regular expression in order to insert the date and time before the file extension.

In Opus 8.1 you can use the * wildcard more than once which means the second line doesn't need to use a regular expression anymore and can be simplified to this:

Rename PATTERN="*.*" TO="* - {date|yyyy-MM-dd} {time|HH-mm-ss}.*" AUTORENAME TYPE=files

The current date and time can be inserted into filenames.
The Go command
 

The Go command is very powerful and has more options than most.

If you want a button which simply takes you to a particular folder, that's easy:

Go E:\Games\Quake\ctf\maps

You can also move relative to the current directory. Say you want a button which opens the parent directory in a new window:

Go Up NEW

Or in a new tab:

Go Up NEWTAB

Parent into a new tab.

One of my three-buttons is used for opening new tabs. Left-clicking it opens a new tab in the current window, showing a second copy of the current folder.

Go CURRENT NEWTAB

Right-clicking the same button will open all the selected folders in new tabs. The nofocus part means the tabs open in the background without switching away from the original tab.

Go FROMSEL NEWTAB=nofocus

Open selected folders in new, inactive tabs.

Middle-clicking the three-button opens the container of all selected folders and shortcuts. This is especially useful when you've done a search and want to go to the directories containing all the matching files:

Go NEWTAB=nofocus OPENCONTAINER=target

Open the container of each selected item in a new, inactive tab.
Create or extract multiple Zips at once
 

This command will create a zip of each selected directory, naming the zips automatically after their respective directories which are created in the current directory. (Opus has a Source and Destination concept and, without the HERE argument, the results would end up in whichever Opus window was designated the Destination.)

Copy ZIP=single HERE

@NODESELECT

Create multiple Zips. This window is set to mix folders and files together.

The next command does the opposite, extracting all selected zip files, creating an appropriately named directory from each zip. It leaves the zips selected so that it's easy to then click the delete button to get rid of them.

Copy EXTRACT=sub HERE

@NODESELECT

Continue to the next page to see more Custom Button Examples, starting with automated image conversion.

Go to Page 5...