FileType

The FileType internal command can be used to:

  • Execute a file-type-specific command or action on selected files

  • Display the context menu for selected items in a drop-down menu

  • Display the context menu items generated by a specific context menu extension

  • Edit the file type definition for the selected file (displays the File Type editor)

  • Display the system New menu (that lets you create new files and folders)

  • Create a new file of a specified type

  • Display the system Open With menu (that lets you choose the program to open selected files with)

  • Display the system Send To menu (that lets you send selected files and folders to various locations or programs)

  • Display a visual summary of file types in the current folder

Command Arguments:

ArgumentTypePossible valuesDescription

ACTION

<event>

Trigger a file-type-defined event for the selected files. For example, you could use this to trigger the drag-and-drop event for a file from a button or hotkey. This is the default argument for the FileType command - you do not need to specify the ACTION keyword.

The value must be one of the following event keywords: open, explore, find, print, shellex, drop, dropshift, dropctrl, dropalt, dblclk, dblclkshift, dblclkctrl, dblclkalt, mdblclk, mdblclkalt, mdblclkshift and mdblclkctrl.

Example: FileType drop

The shellex (shell execute) action is special in that it bypasses most of Opus's own logic and configuration/overrides, passing the request to the Windows shell to execute. When used by itself, it will do the same thing as double-clicking the target file or folder in File Explorer. This is usually the same as the dblclk (double-click) action, which in turn is usually the same as the open action, but there are differences between Opus and the shell, as well as configuration overrides in Opus which do not affect the shell. You can further modify what the shellex action does using the SHELLCLASS and SHELLVERB arguments.

CONTEXTFORCE

/S

(no value)

When used with the CONTEXTMENU argument, this overrides the Hide Windows items on file context menus option on the Miscellaneous / Windows Integration page in Preferences.

Example: FileType CONTEXTMENU CONTEXTFORCE

CONTEXTMENU

/O

(no value)

Displays the standard system context menu for the selected files and folders (acts as a dynamic button). This lets you embed the context menu in a drop-down menu (used in the default File menu, for example). You could also use this in conjunction with the CONTEXTFORCE option to shunt the full Windows context menu into a sub-menu of the normal context menu.

Example: FileType CONTEXTMENU

<GUID>

Displays any context menu items added by the specified context menu extension. This gives you the ability (in conjunction with the Hide Windows items on file context menus option) to control exactly which context menu items are shown on your context menu. You need to know the GUID for the context menu extension in question, and finding that out is beyond the scope of this help file - instead, see this article on the Opus Resource Centre for an example of how this might be used.

Example: FileType CONTEXTMENU {FB314ED9-A251-47B7-93E1-CDD82E34AF8B} CONTEXTFORCE

<file class>

Displays any context menus for the specified file class. This gives you the ability (in conjunction with the Hide Windows items on file context menus option) to control exactly which context menu items are shown on your context menu.

Example: FileType CONTEXTMENU jpegfile

CONTEXTOPTIONS

/K

INCLUDE=<type>

When used in conjunction with CONTEXTMENU Directory\Background, this lets you include specific file types (and exclude all others) from the generated shell New menu that is added. Note that you must enclose the value in quotes, as it contains an equals sign that would otherwise confuse the command parser.

Example: FileType CONTEXTMENU Directory\Background CONTEXTOPTIONS "INCLUDE=.bmp,.jpg,.gif"

EXCLUDE=<type>

Exclude the specified file types from the generated shell New menu when used with CONTEXTMENU Directory\Background. You can also use * to totally disable the New menu in this context.

Example: FileType CONTEXTMENU Directory\Background CONTEXTOPTIONS "EXCLUDE=*"

windowsonly

You can specify CONTEXTOPTIONS=windowsonly to add all "Windows" context menu items in one go. (This means all context menu items which are not specific to Opus, and can include menu items added by 3rd party programs using the Windows context menu API.)

You can use this in conjunction with the Hide Windows items on file context menus Preferences option to move all "Windows" context menu items to a submenu.

Unlike INCLUDE and EXCLUDE (described above), windowsonly is not restricted to the Directory\Background menu.

Example: Filetype CONTEXTMENU CONTEXTOPTIONS=windowsonly

EDIT

/S

(no value)

Displays the File Type editor for the file type corresponding to the selected file. You could add this command to the context menu for All Files and Folders to enable you to quickly edit the file type definition for any file.

Example: FileType EDIT

FILE

/K/M

<filename> ...

Specify the filename or names to perform the file type action on. If not specified, all selected files in the current source folder will be used.

Example: FileType open FILE C:\Data\sales.xls

FILECONTEXT

/S

(no value)

Creates a button which, when right-clicked, shows the context menu for the file or folder the FILE argument points to. When left-clicked, the button acts the same as it would without FILECONTEXT argument.

(This must be used in a normal button's left-click action to modify what right-clicking the button does. It won't work in a "three-button" which has independent left, middle and right-click actions.)

Example: FileType ACTION=dblclk FILECONTEXT FILE="C:\MyApp.exe"

FROMCLIPBOARD

/O

(no value)

Use in conjunction with the NEW argument to create one or more new files with names drawn from the clipboard contents. This is designed to be step two of a two-part operation; the first part being copying the names of one or more files to the clipboard with the Clipboard COPYNAMES command.

Opus will make a new file of the specified type for each filename on the clipboard. If the clipboard contains fully qualified pathnames the new files will be created in the same location as the source files (unless overridden by the PATH argument). If the clipboard contains only filenames without paths, the new files will be created in the current source file display.

Example: FileType NEW=.txt FROMCLIPBOARD

keepext

Specify this argument to preserve the file extensions of the files on the clipboard.

Example: FileType NEW=.txt FROMCLIPBOARD=keepext

HEADING

/O

(no value)

When used with commands which generate a list of items (see dynamic buttons), the HEADING argument adds a small heading at the start of the list. The heading will be hidden when the list is empty. Headings only happen for commands which potentially generate multiple items at the same level as the button itself.

When HEADING is used by itself, without specifying a text value, the main button's label text is used for the heading.

Example: FileType SENDTOMENU=nosub HEADING

<heading text>

You can specify the heading text if you want it to be different to the button's label.

Example: FileType CONTEXTMENU HEADING="RMB menu"

NEW

/K

<file type>

Create a new file of the specified type. This is equivalent to selecting the appropriate item from the New context menu. Only files that have a registered "new" handler can be created in this manner - so if a file type doesn't appear in the New context menu you won't be able to create one with this command. Use the NEWNAME argument to modify the default name of the new file.

You can also create directories by specifing directory as the file type.

Example: FileType NEW .txt Example: FileType NEW=directory NEWNAME="My Dir"

The FileType NEW command automatically sets a variable called newfile to the name of the newly created file. To insert the variable, use {$newfile}.

NEWCOUNT

/K/N

<count>

Allows the creation of more than one new file at once. This is the equivalent of running the FileType NEW command multiple times.

Example: FileType NEW .txt NEWCOUNT 10

NEWMENU

/S

(no value)

Displays the shell New menu, that lets you create new files of various types by selecting the appropriate item from the menu (acts as a dynamic button). This lets you embed the New menu in a drop-down menu.

Example: FileType NEWMENU

NEWNAME

/K

<new filename>

Specifies the filename when creating a new file via the NEW argument. If you don't specify the name, a default filename is used. By default, when a new file is created Opus will initiate inline rename on the new item allowing you to rename it. If you want to specify your own filename and prevent the inline rename behaviour, prefix your filename with the norename: string.

You can also specify a second filename that's used when the primary filename already exists. This is most useful in conjunction with the NEWCOUNT argument, to create multiple files at once. In that case, Opus will normally append an incrementing number (in brackets) to the end of the filename - by specifying a second filename using the NEWNAME argument you can control where that number is inserted. To do this, add a colon to the end of the new name, followed by the second name. Use the %c code to mark where you want the number inserted. You can also specify that the number should be zero-padded using %Nc - e.g. %5c to pad to 5 digits. You can also omit the primary filename and have the first file auto-numbered as well if desired.

Example: FileType NEW .txt NEWNAME "norename:Text File.txt" Example: FileType NEW .txt NEWNAME=":Text %3c.txt" NEWCOUNT=20

OPENWITHMENU

/S

(no value)

Displays the shell Open With menu, that lets you choose the program to open selected files with (acts as a dynamic button). This lets you embed the Open With menu in a drop-down menu.

Example: FileType OPENWITHMENU

PATH

/K

<path>

Use this in conjunction with the NEW argument to create a new file in a location other than the current source file display. Note that when you use this argument the newly created file will not be put into inline rename mode automatically.

Example: FileType NEW .txt PATH "{destpath}"

SENDTOMENU

/S

(no value)

Displays the shell Send To menu, that lets you send selected files and folders to various programs and destinations (acts as a dynamic button).

Example: FileType SENDTOMENU

nosub

By default the Send To menu is displayed as a sub-menu; by adding the nosub value the items within the Send To list will be added directly to the toolbar or drop-down menu containing the FileType SENDTOMENU command.

Example: FileType SENDTOMENU=nosub

shift

Forces the Send To menu to be built as if the <Shift key were held down. On some versions of Windows an extended menu is shown when Shift is held.

Example: FileType SENDTOMENU=nosub,shift

SHELLCLASS

/K

<class>

When used in conjunction with ACTION=shellex, the SHELLCLASS argument lets you specify the name of a file type or application class which the shell should use for execution. These names come from the HKEY_CLASSES_ROOT part of the Windows registry. Specifying a class allows you to tell the shell to open a file using a particular program even if it is not associated as the default handler for the file type.

Example: FileType ACTION=shellex SHELLCLASS=Photoshop.Image.20

Note that, while this can be useful for things like Microsoft Store apps that cannot be run in a normal way, there are generally much easier ways of doing this! If you just want to run a particular program on a particular file, you can usually run the program directly and pass it the {filepath} argument. A less contrived version of the example above would not use the FileType command at all:

C:\Program Files\Photoshop\Photoshop.exe" {filepath}

SHELLVERB

/K

<verb>

When used in conjunction with ACTION=shellex, the SHELLVERB argument lets you specify the file type verb to ask the shell to execute. This overlaps with some of the other possible values of the ACTION argument, with the main differences being that execution is performed by the Windows shell instead of Opus, and that you have the possibility of using the SHELLCLASS argument at the same time.

Example: FileType ACTION=shellex SHELLCLASS=Photoshop.Image.20 SHELLVERB=print

SUMMARY

/O

<no value>

Displays a dialog containing a pie chart that indicates the types of files in the current folder and their relative proportions.

The dialog has a number of options:

  • Selected/All - whether the chart refers to all files in the folder or only the selected ones

  • File count/Size - whether the filetypes are sorted by the number of files (count) or their total size

  • Extensions/Groups - whether the chart represents individual file extensions or file type groups.

By default the dialog remembers its last-used settings. You can use the optional arguments for this command to override the defaults.

Example: FileType SUMMARY

all

The pie chart should refer to all files in the folder rather than selected files.

Example: FileType SUMMARY=all

ascending

File types should be sorted in ascending order (smallest group to largest) rather than descending order. Note that this option is currently not available via the user interface, only the command line.

Example: FileType SUMMARY=groups,ascending

count

File types should be sorted by total number of files.

Example: FileType SUMMARY=count

ext

File types should be grouped by extension rather than file type group.

Example: FileType SUMMARY=ext,all

groups

File types should be grouped by file type group rather than extension.

Example: FileType SUMMARY=groups

nomerge

By default "similar" file types are treated as the same, for example *.jpg and *.jpeg. Use the nomerge option to split those out and treat them as individual types.

Example: FileType SUMMARY=nomerge,size

selected

The pie chart should refer only to selected files in the folder, rather than all files.

Example: FileType SUMMARY=selected

size

File types should be sorted by the total file size rather than the number of files.

Example: FileType SUMMARY=size,ext

最后更新于