XDIR
Screenshot of XDIR

Introduction

XDIR is a replacement for the resident DIR command of the Windows command line. It is a Win32 application and will not real mode DOS. Win32 Lib or other special files are not required, only the standard Euphoria include files. It has been tested under Windows 95, Windows 98, Windows NT4, and Windows 2000. No testing was done on Windows ME or Windows XP but should run without problem. It accepts all of the options (one renamed) of the Win2000-XP version, producing similar results, and adding many new features. Many new options have been added along with a number of other enhancements.

Features overview:

  1. Almost 100% compatibility with resident command.
  2. Multi-column display.
  3. Display of Zip file contents.
  4. Tree view of subdirectory or entire volume.
  5. Can show space consumed by subdirectories.
  6. Detailed Drive and File information.
  7. Lists all avalable drives.
  8. Display 4DOS compatible file descriptions.
  9. Display more than 70 file types.
  10. Extensive customization options.
  11. Multiple file selection and exclusion patterns.
  12. Filter files by size or date.
  13. Customizable colors for different file extensions.
  14. Support for network drives using the UNC convention - \\<servername>\<sharename>\
  15. Number of files limited only by memory.
  16. Forward and reverse scrolling within directories.

Usage:

Since XDIR is a Win32 console application it must be executed with EXWC.EXE. EXWC.EXE is not supplied with the Euphoria distriibution but may be easily created. From the command line go to the EUPHORIA\BIN subdirectory and type MAKECON. This will copy EXW.EXE to EXWC.EXE and make the necessary changes. EXWC.EXE performs identically to EXW.EXE but does not create a new console when it first does console IO.

While XDIR may be run with the command "EXWC XDIR.EXWC", this is clearly not a convenient option for general use. There are a number of ways whereby XDIR may be executed by typing it's name, just as with any non-resident command. (#4 is probably best).

1. The ideal way would be to use the Euphoria BINDW command to create a standalone program which could be used on any machine, including those that do not have Euphoria installed. Unfortunately this command is only available in the full commercial Euphoria distribution. Another alternative would be to the Euphoria to C conversion program to create a standalone program, but only the commercial version is appropriate for this purpose.

2. On Windows NT, Windows 2000, and Windows XP, it is possible to configure the system to recognize and execute directly programs having an EXWC extension. The EXWC extension must be added to the "PATHEXT" environment variable and then the necessary associations created in windows folder options. It can be a little tricky to perform this operation and it will not be explainmed here. The Windows help files should contain the necessary instructions, at least on Windows 2000 and XP. This option is NOT available for Windows 9x operating systems.

3. A batch file may be created that contains the necessary instructions. An example would be:

@ECHO OFF
EXWC C:\EUPHORIA\PROGRAMS\XDIR.EXWC %1 %2 %3 %4 %5 %6 %7 %8

If a batch file contains the above command and is named "XDIT.BAT", it may be executed by simply typing XDIR at the command line. The path in the example must be modified according to your system environment. This option works well on Windows NT platforms but it has a problem with Windows 9x and ME. All operations should work but IO redirection will not be possible. "XDIR >file" will create the file but it will contain no data. This is caused by the implementation of batch files on these platforms and not by XDIR itself. IO redirection does work as expected on all NT platforms.

4. DOSKEY may be used to create a macro to execute the command. This is quite easy to do, works on all platforms, and allows IO redirection on all platforms. This is the recommended option for most situations. Create a file containing the the following and save it to a convenient location:

DOSKEY /ECHO:OFF XDIR=EXWC C:\EUPHORIA\PROGRAMS\XDIR.EXWC $*

A suitable name would be MACROS.BAT. "XDIR" may be shortened to "D" for convenience and the path must be modified according to your system.

We must now configure the system to execute MACROS.BAT when the command shell opens. Right click on the shortcut to the shell, select properties, and click on the Program tab. Under "Batch File:" enter the path where MACROS.BAT was saved. Click on "OK".

DOSKEY is not run by default on Windows 9x platforms. Simply add the following line to the AUTOEXEC.BAT file:

DOSKEY

NOTE: This is only necessary for Windows 9x and Windows ME systems. This will also enable full command-line editing. Type "DOSKEY /?" at the command prompt to see the other options that are available. After a reboot the functions of DOSKEY will be available in all console windows.

Options:

The compatible options are virtually identical to those available in the resident command and will not be covered here. The display layout is very similar but differs somewhat in detail. The operating system in use is detected and the default listing format is adjusted accordingly.

/AAttribute option has been enhanced to accept C-Compressed, and E-Encrypted options.
/ATT Show attributes.
/CLR Clears display before listing.
/Cn Set color level.
n=0-No color, 1-Column entries, 2, Files by extension, 3-Both
/COMP Show compressed file size and compression ratio.
/DI Displays list of all drives available plus volume name, etc.
/F Shows full path name instead of long file name.
/FA Show archive files only.
/FD Filter by date.
/FS Filter by size.
/FT Show document files only.
/FX Show Executable files only.
/H Sort columns horizontally.
/I Displays information for selected drive or file.
/J Show colors used for recognized extensions.
/K Show file sizes in KB, MB, GB, and TB as appropriate.
/M Customize listing. Covered in detail below.
/NH Suppress display of header and summary information.
/PX Same as /P but clips long lines, allowing bi-directional scrolling.
/SEC Show seconds in time display. Default is off.
/SIZE Displays space consumed by all subdirectories in listing.
/TREE Displays tree listing of selected drive or subdirectory.
/U Files displayed in uppercase.
/UTC Show file dates in UTC time instead of local time.
/V Verbose listing. Similar to Windows9x DIR command.
/VER Display program version, build, and location.
/WIDTH   Sets display width. Primarily used when output has been redirected to a printer.
/WC Case sensitive wildcards.
/Wx Select filename to match against.
x=S Short name, x=L Long name, x=B Both[default].
/X If used with /D, /W, /B, /F options, will display DOS 8.3 short names. Otherwise adds short name in default listing.
/Y2 Forces 2 digit year display.
/Y4 Forces 4 digit year display. Same as /4 in resident command.
/Z Display 4DOS compatible file descriptions.
/n Selects number of display columns.
/0 Adjust number of columns as necessary to display file size and name.
/. Do not display . amd .. directory entries.
/! Specify a pattern(s) for files to be excluded from the list.
/24 Force 24 Hour time display.
/? Display Help screen.
/?? Open Help file in Internet explorer.

Note: /ATT, /Q, and /X are mutually exclusive.

Compatibility:

Compatibility with the resident DIR has always been a high priority for XDIR. All options available on the WindowsXP version have been implemented with the sole exception of the /4 option which has been replaced with /Y4. The default listing mode is set to that of Windows9x or NT platform as appropriate.

Multi-column display:

The /# option sets the number of columns that will be displayed, ranging from 0-9. If # is 1-9 then the amount of information displayed is adjusted as necessary to provide the requested columns. The information ranges from Date-Time-Attributes-Size-Name down to Name only. Columns 1 and 2 will use Long File Names by default but 8.3 short names may be forced by the /X switch. Columns 3 and greater will use short names by default but may be overridden with the /-X option.

The exact format of the display may be set by the /M option. If this is done, the format will never be overridden, and the number of columns will be adjusted downwards as necessary. The number of columns will never be greater then requested.

If # is 0 then the display format is always Size-Name, with the number of columns auto-adjusted to the maximum possible. Names will default to Long File Names

Custom listing options:

Probably the most powerful feature of XDIR is the capability to custom design the listing to show exactly what is desired. The /M option is followed by a code character for each element desired for the listing. Example:

XDIR C:\ /MTSN will display T-Date and Time, S-Size, and N-Long filename of the C:\ directory.

A     Attributes.
C Compressed file size.
D Date. Optionally followed by 1-Creation Date, 2-Access Date, 3-Modified (Default)
H File attributes as 4 hex digits.
J Justified 8.3 file names.
L Allocated space used by file.
M Compression method for Zip files.
N Long file name.
Q File owner. Ignored on Windows9x.
R Compression ratio for Zip files.
S Size.
T Date & Time. Same options as D.
X 8.3 short filename. (unjustified).
Y File type according to extension.
Z 4DOS compatible file description.
_ Adds extra space between elements. Default is one space.
3 CRC-32 file checksum for Zip files.
8 Same as J but only if short name exists, blank otherwise.
"" Text between double quotes will be inserted directly in the listing. Useful for creating batch files.

Multiple Wildcards, Exclusions:

The resident DIR command offers reasonably good pattern matching with the "?" and "*" characters, but only one pattern may be specified. XDIR extends this to support multiple patterns, separated by commas, in the same command. As an example:

XDIR *.exe,*.com will list all .exe and .com files in the current directory.

Spaces may be included and will be treated the same as any other character. If spaces are used anywhere in the path specification it must be enclosed by double quotes, otherwise the shell will regard them as seperate paths.

The switch /! allows specification of a pattern for files that should be excluded from the listing. As an example:

XDIR /!*.exe,*.com will list all files in the current directory, except .exe and .com files.

Normal wildcards and exclusions may be combined.

Enhanced pattern matching:

Pattern matching in XDIR has been extended to take in a subset of that available on unix systems. At present this is restricted to those concerned with individual characters. DIR has the "?" symbol that will match any character, while XDIR can further refine such matches such that certain specific characters, or a range of characters be present. The specifications are contained within set of square brackets. Example:

[ACK] which would match the characters a,c,and k.
[A-L]*.* would match all files that start with the characters A to L.
[A-FVZ]*.* would match al files starting with the characters A to F, V or Z.

Such patterns may be contained within either the filename or the filename extension. If the pattern is preceded by the "!" character then a succesful match would exclude the file from being listed. Example:

[!AMZ]*.* would exclude files that begin with the characters A,M, or Z.

There is one restriction as to where such a sequence may be specified. DIR and XDIR allows a specification such as *DIR* which would match any file that conatins the string "DIR". The extended character matching sequence may not be used following the * character. This applies seperately to the filename and it's extension. Since the bracket and - characters are legal characters within filenames, there must be a means of treating them literally. Any pattern that is enclosed within either single or double quotes will be treated literally and processed by the normal pattern matching rules. There is no provision for treating the "*", "?", "/", or space characters literally. Spaces may never never appaear in a file specification except when surrounded by double quotes. As with the usual pattern matching rules, characters are not case sensitive unless the /WC option is specified.

Date & Time display:

Date and time formats will normally default to those set by Control Panel - Regional Settings, just as with the resident DIR. Leading zeros will be inserted, even if not specified in system settings. These settings may however be overridden by command line options. /Y4 replaces /4 in the resident command and forces 4 digit year display, while /Y2 forces a 2 digit display. /24 forces 24 display format, while /SEC will include seconds in the display. If system settings specify a 24 Hour format this can not be overridden.

Configuration:

XDIR will check for and use the XDIRCMD environment variable if it is present. It contains a default set of options and works similar to the DIRCMD variable of the resident command. If XDIRCMD is not present, DIRCMD will be used if present. If neither is present then the same defaults are used as the resident version. All preset options may be overridden at the command line. The special options of XDIR could be added to DIRCMD but this is not recommended as they would give errors to the resident command.

The colors used when color display is in effect are set by the file "XDIR.INI" which should be in the same directory as XDIR. See the sample file provided for the required format

Other features:

The /P option works as in the resident version of DIR, but with a number of enhancements. After the screen is filled a line at the bottom of the screen will offer a number of options:

"ESC-STOP"Pressing the escape key will abort the current listing.
"SPACE-Next"Pressing the space key will advance display by one screen.
"Cursor up dn"Bi-directional scrolling is available in all but treeview mode. Reverse scrolling is not available if line wrap is required in the list.
"N-Continuous"Pressing "n" or "N" will continue the listing without pause.
"BS-Back"Pressing the backspace key will go back one screenfull. This is not available during tree listing.

If the ESC key is hit at any time during scrolling, the same line will be brought up, even if the /P option was not specified. As with the resident command, Control C will abort the listing.

The contents of ZIP files may be listed, just as if it were a directory. The default listing format will then be Date&Time, File size, Compression method, Compressed size, Compression ratio, CRC-32, and Long file name. This may be overiddden by the usual means. If the ZIP file contains directories or other ZIP files, they will be shown but their contents may not be examined. This feature is completely contained within the program and does not rely on any external programs.

The width of the size field and certain others is not fixed but is adjusted according to requirements. This means less wasted space and more available space for display of long file names. All elements of a single listing will be the same width so columns will continue to line up.

The width of the display screen is sensed and is made available for use. On Windows NT platforms the size of the virtual screen may be much larger then the physical window. The Euphoria text output routines appear to have a problem with screens of wider than 80 characters. Because of this problem, all screen output is performed by the windows console routines which do not have these restrictions.

Other issues:

In some cases the exact listing format may vary according to the order options are present on the command line. Ordinarily options may be given in any order, before or after the path specification. When contradictory options are used the results may be unpredictable. The program has not been extensively tested so some errors may be present. Use at your own risk.

Larry Miller
larrymiller@sasktel.net