xplorer² Quick Start Guide
File exploring reinvented: Feel like home miles away from home

Automation of DOS (and windows) commands

In spite of the drag-drop and click-happy era of file management we're living in, for some tasks you can't beat the efficiency offered by traditional command line execution of programs. In the old days, instead of clicking on icons to start a program, one had to type its path/name in a command processor window (DOS console). This may seem quaint and antiquated but it is very powerful since you can specify extra arguments that modify the behaviour of the program in question, specify which files to operate upon etc.

xplorer² brings the command line into the third millennium, easing its use while maintaining all its power and flexibility. If you are familiar with the DOS console, you can regard the active pane cum addressbar combination as a graphical console that shows the folder contents of the "current directory" at all times. As you browse folders the "current directory" is updated automatically, and the commands you type can access the folder contents directly.

You can start composing text commands using Tools | DOS command, or just get into the addressbar with <Shift+Tab> and type the special prompt $ character that instructs xplorer² to interpret the input as a DOS command - otherwise it could be mistaken for a folder path. For instance typing $ dir and pressing <Return> will execute the DOS dir command, producing the listing of the current folder's contents - arguably not the most useful command within x²'s context!

NOTE: The commands you type correspond to names of executable files that exist on disk - minus the .exe or .com extension - and in the end of the day launch the respective application. So you must make sure you type the names correctly and that the files themselves can be located. If you have a program called windiff.exe located in c:\tools and you want to call it while browsing c:\work, then you must type its complete path in the addressbar, e.g. $ c:\tools\windiff. Alternatively you can add c:\tools to the PATH environmental variable and reference it just by name.

Except for DOS commands ($-prompted) you can also execute generic windows programs using the special character >, e.g. typing > winword will launch MS Word. In this sense you have all the functionality of the standard Start | Run menu straight from the addressbar. This execution mode is mostly for programs that have their own user interface and don't need a console window for their output.

Except for launching both DOS and windows commands, the addressbar assists you during the typing process in a number of ways:

Commands launched from the addressbar normally apply only to the single focused item in the active folder view. If you want to apply the command to all the selected items use a double prompt character, e.g. >> or $$. This construct is a simple road to scripts without a dialog window.

$-Tokens start tools and pass arguments

Instead of typing specific filenames as parts of a command, you can use special characters that get automatically substituted with the name of the item(s) that happen to be selected when a command is executed. For example the commands $type file1 and $type $N are equivalent if file1 is the focused item in the active folder pane. Using special tokens like $N saves keystrokes and allows for reusable commands. So whereas $type file1 can only be used to type (show the contents of) file1, the version with $N can be used to type any file, as long as it is selected in the active view.

There is a variety of $-tokens, each representing a different part of the active item or even the all selected items taken as a whole. Let's use a hypothetical situation to clarify the meaning of each $-token. Suppose we have a dual-pane arrangement where the right view is active and the contents are:

The following table lists all the available tokens. The third column shows what each token would have been substituted for, given the above scenario. Unless stated otherwise all tokens act on the single focused (or active) item in each pane.

$NLocal filenameactive.cpp
$BBase name (before .)active
$EFilename extension (past .)cpp
$PParent folder pathc:\work\c++
$DFile modification date13/3/2004 10:12
$CParent folder plain namec++
$FFull path namec:\work\c++\active.cpp
$UUNC path name (network accessible)\\comp\share\active.cpp
$SAll selected filenamesactive.cpp file.txt
$AAll selected filenames (fullpaths)c:\work\c++\active.cpp
$>Like $A but selected fullpaths are saved to the list file
%TEMP%\x2tmpList.txt and this file is used as argument
$LLeft (top) pane pathc:\music
$RRight (bottom) pane pathc:\work\c++
$IInactive pane pathc:\music
$QFilename from inactive panetitles.txt
$GPath and filename from inactive panec:\music\titles.txt
$ZTemporary filename extracted from zipfolder, FTP, etc
Within normal filesystem folders it behaves like $F
$nnAutomatically incremented counter starting from number nn
Possible counter formats are $1 for the sequence 1,2,...
$001 for 001,002,..., $5 for 5,6,... and so on
$[s:l]Extract part of the filename starting at s and for l letters
$[4:3] will extract 3 letters starting from character 4
Use a negative start to count from the end of the name
$?Asks for an argument(whatever you type)
$$Escape for a single $$

Many of these tokens are intended for renaming large numbers of files, as they are used in File | Mass rename command. But you can use them for any other purpose too; just type as many tokens as necessary in a single command and they will all be substituted according to the above rules.

You may have noticed that all tokens were listed in uppercase. If you type a token in lowercase then it is interpreted in a slightly different fashion, using the short 8.3 version of whatever name the normal uppercase token would have produced. To clarify, had $N corresponded to undocumented.h the lowercase $n would have resulted in UNDOCU~1.H, which is the equivalent old DOS filename.

Another kind of token can be used to extract the text of a particular file column. The generic format is ${column_name}, e.g. ${size} will fill in the file size as it appears in detailed view mode. You can use any of the available columns, which comes handy for mass renaming as e.g. you can use MP3 tags as part of the filename - just make sure you don't use any columns that may insert characters invalid for filenames as * or :.

NOTE: The addressbar in scrap windows also supports command execution. The only difference is the concept of the "current directory". So whereas in normal browser windows the current directory is synchronized with the active folder, scrap windows contain files from many folders and as a result there is no current directory in the DOS sense. Therefore you should only use tokens that carry full path information, e.g. $F instead of $N, otherwise you may have problems addressing the intended files. The tokens $L, $R and $I don't have any meaning for scraps altogether.

[PRO] Command output redirection

Most DOS commands don't have a GUI of their own and rely on the console window for their output. This is the traditional black & white system DOS box, which is rather awkward to use. The "pro" version comes with a substitute console that is nearly equivalent in functionality and much easier to work with, e.g. it can mark and copy text like a normal editor window, search for text, etc.

Figure 18. Console² grabbing the output of DOS commands

This modern version of the DOS console automatically follows the browser window, changing its current directory as you browse folders with xplorer². The working path is shown on its title bar. It receives the output of all $-prompted commands issued from the addressbar and from command scripts, too.

You can also type commands directly in the console window - that's the purpose of the input field shown in figure 18, as well as deliver input to running programs (e.g. Y/N responses). This input area supports path autocompletion with F1 and maintains a history of past commands too.

If despite all the extra functionality you prefer the traditional DOS console, you can disable it from Tools | Options | General. Note that in such a case you'll get a separate console for each command you execute.

Automatic script generation mass rename MP3 files

Commands launched from the addressbar operate only on the single focused item within the folder being browsed (unless a double prompt as >> is typed as discussed above). In some occasions you may need to apply the same command to a number of files as for instance for batch conversions of MP3 files. For this task it is more convenient to use Tools | Command script to treat all selected files in one stroke.

Figure 19. Dialog for batch file generation

In this dialog you specify a command Template that will be applied to each and every selected file name. The syntax is identical to the addressbar commands, using the familiar $-tokens instead of actual file names. Command templates may contain multiple comma-separated commands as the above snapshot illustrates.

The script generator replicates the command template for each selected file in succession. Plain text parts are reproduced verbatim and $-tokens are replaced on a per-file basis. If you have 100 files selected then 100 sets of commands will be generated, effortlessly. Let's have an example using the template ren "$N" "$B_$01$$.$E" on a selection that comprises 2 files, x2help.htm, x2help.ccs.

This template has four special $-tokens, N for the whole name, B for the base, E for the extension and an automatic counter starting from 1 with a leading zero ($01). The double dollar is an escape for a single $. For each file the generator copies the constant parts of the template including spaces and quotation marks, and substitutes the variable parts using the file in question. For our two files this translates to (notice the counter in the second line):

ren "x2help.htm" "x2help_01$.htm"
ren "x2help.ccs" "x2help_02$.css"

NOTE: The use of quotation marks around the filenames covers for situations where names contain spaces. An alternative is to use lowercase token versions like $n that are guaranteed to be free of spaces, albeit rather mangled.

Once the script is generated, there are a number of alternative modes of execution, each activated by a dialog button:

You should note that the wizard is merely manipulating strings and is oblivious about their meaning or command syntax. If you make any mistakes you will notice during execution!

Optional command line arguments

When executed from the command line xplorer² accepts a number of optional arguments that control some aspects of the program. The complete command line is:

xplorer2.exe /F:n /P /R:rootFolder /S:registryKey /L:searchFromFolder /I:settings.REG /M /1 /2 leftFolder rightFolder

All arguments are optional and are described in the following table. The last two arguments - without the / switch character - specify starting left & right pane folders for the main window. These can also be the names of folder groups saved in Customize menu if you want to reinstate a particular set of tabs upon startup.

If you start with a scrap container (/F:1 switch) leftFolder can be a cida file or a name of a folder to flatten.

/FStarting window type. By default a normal browser window is opened, equivalent to /F:0. If you want to start with a scrap window use /F:1
/PBy default xplorer² runs in a system resource-friendly single process mode, even when you launch separate instances. Using /P you force new instances to open as separate processes.
/RRoots the program on a folder other than the default desktop. For instance /R:c:\winnt will force both the tree and view panes on c:\winnt and won't allow users to reach other parts of the namespace unless underneath the root node; e.g. d:\ will be off-limits whereas c:\winnt\system will be accessible
/SRegistry key extension for storing program options. The default key is HKCU\Software\ZabaraKatranemia Plc\xplorer2 but you can have multiple parallel keys with different options. Keys can be changed dynamically with Window | Save layout menu. For instance /S:preview will load options from the key ...\ZabaraKatranemia Plc\xplorer2.preview
/LCauses a scrap window to issue a "Find Files" command when it first comes up; alternatively it could be a saved search .X2FND file. The search is rooted at "searchFromFolder". Can only be used in conjunction with /F:1
/MDoes not allow window to open in minimized mode on startup
/NDo not restore slow folders from last session (e.g. network) in case they are unavailable
/1Forces single pane mode
/2Forces dual pane mode
/TDoesn't restore folder tabs on startup (by default you get all tabs reopened - as you left them at last use)
/DForce xplorer² to nag you for a registration key
/I(portable version) Initialize registry with a custom settings file. The settings file should be in the same folder as xplorer² and be created with Actions | Extract settings on your "home" PC. For ultimate version this can also be a INI file bypassing the registry
/ERun in windows explorer replacement mode
/ZSilently start and stay in the background without a window
/BExecute one of the saved macros (see Customize | Macros menu) when xplorer² starts. For instance "/B:sample macro" will launch the saved "sample macro" (assuming the name exists). This switch is useful for automating tasks using the task scheduler

Figure 20. Shortcut properties including command line options

You can take advantage of these options by creating a desktop shortcut for xplorer². Using the property page, add the required arguments in the Target field, past the executable name. The above snapshot illustrates a shortcut that launches the program using the options /1 c:\, which means start with a single pane and browse folder c:\.

Searching Contents Programming

Download xplorer2

© 2002-2023 ZABKAT, All Rights Reserved