AnyCmd - a Total Commander lister plugin

If you still don't know what Total Commander is, please take several minutes and visit the site: Probably, it is the best file manager for Windows OS. Be careful though - if you start using Total Commander, you will never switch back to another file manager! ;-)

Inspired by AnyELF Total Commander plugin, an idea came - why limit yourself with a special file formats only. Why not permit to user define a custom dumper, text filter, lister or file viewer? After all, there are a lot of command line text processing utilities that already do this job. Definitely, you may use file associations or just use command line window for this purpose. But, would not be it is just great if you could do the job within Total Commander itself? I mean - do anything! You can sort lines of text, compile a program, launch your favorite Perl (really, Perl?) script, and so on.

That is how the idea came, and that is why the plugin was implemented. So, let's start:


Download the file and save it in a temporary location. Open Total Commander, locate the file and double click on it (or just press "ENTER"). Total Commander will prompt you to install the plugin. Accept it. A list of installed plugins will appear. Just press "OK". That is all.

Detection and Command strings

By default, the plugin will work on any file with extension .TXT. When opened with the lister (F3 button), the plugin will show text file content sorted. You may switch between original and sorted text by pressing '1' and '4' correspondingly. If that it is what you want, you are done. But, how can you customize the default settings?

Init files

To change the default setting, you need to write new detection and command strings. You may modify them in the init file. Here is the procedure:

  • Locate lsplugin.ini and wincmd.ini files. Usually, they are located in your User's AppData\Roaming\GHISLER directory. For example, on my computer, the full path is: c:\Users\Serge\AppData\Roaming\GHISLER. One of the way to figure out the proper location is to choose "Configuration/Change Settings Files Directly" menu item. In notepad, choose "File/Save As ...". Mention the directory where the current file is located.

  • In wincmd.ini file, under "[ListerPlugins]" group, remove the current (cached) detection string. Initially it may look like this:



    Where 'x' is a number.
    Remove the second ('x_detect') line.

  • In anycmd.ini, located at the plugin installation directory, adjust "DetectString" and "Command" strings for "AnyCmd" group. Initially, they are looking like this:


    Command=sort.exe %s
    This setting permits to sort text files (files with .TXT extension). Modifying "DetectString" to be


    DetectString=EXT=TXT & FIND("AnyCmd")
    we will sort only those text files that contain "AnyCmd" word inside.

  • Save your changes and restart Total Commander. The new setting should be accepted.

  • Improtant note: You may install several instances of the plugin in different (sub)directories. This permits to define several detection string filters and associate corresponding commands.

  • Improtant note: If anycmd.ini file is not found, lsplugin.ini file is used instead.

  • Detection and Command Strings Examples

    To get started, here go some examples of init files. Please note - %s is substituted by actual file name.

    View file's attributes and full path for .INI files:

    anycmd.ini - View file's attributes and full path for .INI files

    Command=cmd.exe /c attrib %s

    Show only the lines containing specific text. For example, find all procedures in TCL file.

    anycmd.ini - Show the lines containing specific text

    Command=findstr /i "proc " %s

    Compile .CPP file and show errors (if any):

    anycmd.ini - Compile .CPP file and show errors

    Command=cl -c %s

    Invoke a batch file:

    anycmd.ini - Invoke a batch file

    Command=cmd.exe /c c:\mycomp.bat %s

    If the content of c:\mycomp.bat file is like this:


    cl -c /Fatemp.tmp %1
    type temp.tmp
    del temp.tmp

    assembly listing for compiled .CPP file will be shown.

    The only requirement to invoked programs is that they should print out their output to the standard output stream. Your needs, creativity and fantasy will help you continue from this point. Enjoy!

    Please note - command line may contain environment variables:

    Environment variables

    Command=%COMMANDER_PATH%\plugins\wlx\anycmd\myprog.exe %s

    Standard output and standard error streams

    By default, the plugin redirects both standard output and error streams to the lister window. You may change this behavior. Stream selection is controlled by "Stream" key in the initialization file. Value '1' selects standard output; value '2' - standard error and '3' (default) - both streams.

    Appendix: Detection Strings Syntax

    This section describes the detection string syntax. It is taken from "Lister Plugin Guide".

    The syntax of the detection string

    The syntax of the detection string is as follows. There are operands, operators and functions.


    EXTThe extension of the file to be loaded (always uppercase)
    SIZEThe size of the file to be loaded.
    FORCE1 if the user chose 'Image/Multimedia' from the menu, 0 otherwise.
    MULTIMEDIAThis detect string is special: It is always TRUE (also in older TC versions). If it is present in the string, this plugin overrides internal multimedia viewers in TC. If not, the internal viewers are used. Check the example below!
    [5]The fifth byte in the file to be loaded. The first 8192 bytes can be checked for a match.
    12345The number 12345
    "TEST"The string "TEST"


    &AND. The left AND the right expression must be true (!=0).
    |OR: Either the left OR the right expression needs to be true (!=0).
    =EQUAL: The left and right expression need to be equal.
    !=UNEQUAL: The left and right expression must not be equal.
    < SMALLER: The left expression is smaller than the right expression. Comparing a number and a string returns false (0). Booleans are stored as 0 (false) and 1 (true).
    > LARGER: The left expression is larger than the right expression.


    ()Braces: The expression inside the braces is evaluated as a whole.
    !()NOT: The expression inside the braces will be inverted. Note that the braces are necessary!
    FIND()The text inside the braces is searched in the first 8192 bytes of the file. Returns 1 for success and 0 for failure.
    FINDI()The text inside the braces is searched in the first 8192 bytes of the file. Upper/lowercase is ignored.

    Internal handling of variables

    Varialbes can store numbers and strings. Operators can compare numbers with numbers and strings with strings, but not numbers with strings. Exception: A single char can also be compared with a number. Its value is its ANSI character code (e.g. "A"=65). Boolean values of comparisons are stored as 1 (true) and 0 (false).


    EXT="WAV" | EXT="AVI"The file may be a Wave or AVI file.
    EXT="WAV" & [0]="R" & [1]="I" & [2]="F" & [3]="F" & FIND("WAVEfmt")Also checks for Wave header "RIFF" and string "WAVEfmt"
    EXT="WAV" & (SIZE<1000000 | FORCE)Load wave files smaller than 1000000 bytes at startup/file change, and all wave files if the user explictly chooses 'Image/Multimedia' from the menu.
    ([0]="P" & [1]="K" & [2]=3 & [3]=4) | ([0]="P" & [1]="K" & [2]=7 & [3]=8)Checks for the ZIP header PK#3#4 or PK#7#8 (the latter is used for multi-volume zip files).
    EXT="TXT" & !(FINDI("") | FINDI(""))This plugin handles text files which aren't HTML files. A first detection is done with the and tags. If these are not found, a more thorough check may be done in the plugin itself.
    MULTIMEDIA & (EXT="WAV" | EXT="MP3")Replace the internal player for WAV and MP3 files (which normally uses Windows Media Player as a plugin). Requires TC 6.0 or later!

    Operator precedence:

    The strongest operators are =, != < and >, then comes &, and finally |. What does this mean? Example: expr1="a" & expr2 | expr3<5 & expr4!=b will be evaluated as ((expr1="a") & expr2) | ((expr3<5) & (expr4!="b"))

    If in doubt, simply use braces to make the evaluation order clear.

    The project and the page is maintained by Serge Lamikhov-Center.

    Project Web Hosted by

    Get ELFIO library