Glindra
Documentation Index Download
Command Line File Handling and ASCII Tools

d - Directory


The program d is a command line utility that lists the files in one or more directories. It is much like dir in DOS, or ls in the standard Linux shells.

In addition to the normal functions of a directory program, it can calculate file size totals at any desired resolution. This is useful for providing an overview of disk usage.

Example (Windows)
> d c:\windows\*** -resolution=20mb

    76.6 Mb    c:\windows\$hf_mig$\***\
   305.8 Mb    c:\windows\$NtServicePackUninstall$\***\
    36.3 Mb    c:\windows\$xpsp1hfm$\***\
    76.7 Mb    c:\windows\Driver Cache\I386\DRIVER.CAB
    22.3 Mb    c:\windows\Driver Cache\I386\sp2.cab
    22.8 Mb    c:\windows\Fonts\
    48.7 Mb    c:\windows\Help\SBSI\Training\WXPPRO\Content\Lib\
    47.7 Mb    c:\windows\Help\SBSI\Training\WXPPRO\Content\Wave\
    20.2 Mb    c:\windows\Help\Tours\mmTour\
    38.5 Mb    c:\windows\Help\***\
    56.9 Mb    c:\windows\INF\
    27.2 Mb    c:\windows\Installer\***\
    41.7 Mb    c:\windows\PCHEALTH\HELPCTR\***\
    56.8 Mb    c:\windows\RegisteredPackages\***\
    22.4 Mb    c:\windows\REPAIR\
    24.9 Mb    c:\windows\ServicePackFiles\i386\lang\
   478.4 Mb    c:\windows\ServicePackFiles\i386\
    22.3 Mb    c:\windows\ServicePackFiles\i386\sp2.cab
    36.9 Mb    c:\windows\SYSTEM32\CONFIG\***\
   273.4 Mb    c:\windows\SYSTEM32\DLLCACHE\
    32.4 Mb    c:\windows\SYSTEM32\DRIVERS\***\
    37.9 Mb    c:\windows\SYSTEM32\MUI\***\
    24.3 Mb    c:\windows\SYSTEM32\SPOOL\DRIVERS\W32X86\3\
    33.1 Mb    c:\windows\SYSTEM32\SPOOL\DRIVERS\W32X86\***\
    26.2 Mb    c:\windows\SYSTEM32\WBEM\***\
   514.1 Mb    c:\windows\SYSTEM32\***\
   210.5 Mb    c:\windows\***\
  ----------
  2.7 Gb       grand total, 17659 files in 614 directories
See the description of the -resolution option for further information.


The most common use of the d command, however, is to list files and directories, just like Windows dir or Unix ls.

Example (Linux)
> d '*.html'

Directory of /home/chris/work/

505 19-Mar-2001 14:21:06 about.html
3 kb 9-Jun-2002 17:39:18 index.html
----------
3 kb total, 2 files


Example (Windows)
> d *.html

Directory of e:\work\

505 19-Mar-2001 14:21:06 about.html
3 kb 9-Jun-2002 17:39:18 index.html
----------
3 kb total, 2 files


Parameters

Input File Specification And Wildcard Syntax

Example (Windows)
> d *.htm*

The d command takes one or more filenames, with or without wildcards, as parameter. If no filename is given, the default is to list all files in the current directory.

The * and ? wildcards have their normal meanings in file names. Square brackets [xyz] can be used to specify sets of characters.

Under Linux, filenames that contain wildcard characters must be enclosed in single quotes, to prevent the shell from expanding the wildcards ("globbing").

Example (Linux)
> d '*.htm*'


The directory delimiter is backslash under Windows and forward slash under Linux. For filenames that are enclosed in single quotes, you can use forward slash under Windows as well.

Example (Windows and Linux)
> d 'work/*.htm*' -since=1-may -noheader
The above command works under both Windows and Linux.


In directory paths, the special wildcard *** means "...and all its subdirectories".

Examples (Windows)
d ***\a.xyz All files named a.xyz in the current directory, or any of its subdirectories.
d \***\b.xyz All files named b.xyz in any directory on the disk.
d \***\old\c.xyz All files named c.xyz in any directory named old.

See Filenames for further information about how the filename is divided into parts, and about the wildcard syntax.

You can specify multiple filenames on the command line, separated by spaces. To specify a filename that contains spaces or other special characters, you enclose it in quotes. This works for filenames that contain wildcards as well.


Options

You can specify files using various wildcards and options, and use other options to control how the output is formatted.

Command options can start with a dash (-), two dashes, (--), or, on Windows, a slash (/). There are no semantic differences between the three variants. The option names are usually English words. You can write them out in full or truncate them, normally to two characters, as long as they are unique.

Options can be negated by putting no before them, so -noheader is the opposite of -header.

Example (Windows and Linux)
> d -since=1-may -noheader
> d --since=1-may --noheader
Example (Windows)
> d /since=1-may /noheader

See Parameters and Options for more about the command line syntax.

File Selection Options

Example (Windows)
> d *** -exclude=(.doc .txt) -before=today -min_size=2mb -hidden=also
Example (Linux)
> d '***' -exclude=\(.doc .txt\) -before=today -min_size=2mb -hidden=also
Options
-since [= datetime] Select files that were created on or after a certain date/time.
-before [= datetime] Select file that were created before a certain date/time.
-min_size [= size] Specify a minimum file size in bytes, Mb, or some other unit
-max_size [= size] Specify a maximum file size .
-directories [= only/also/not]
List directory files (only/also/not) . Default is also.
-hidden [= only/also/not] List hidden files (only/also/not). Default is not.
-nodefault Do not add any default wildcards or other filename parts to the filename.
-exclude [= filespec] Exclude files that match the file specification given as option value. If the option value is enclosed in parenthesis, it can contain a full file specification, including recursive file selection options.
-current_only List only the current version of the files by default. This option can be overridden by the file specification and/or the -default option. The -current option is specific to the d directory command.

These options control which files are selected. See File Selection Options for more information.


Output Control Options

Example (Windows)
> d *** -totals -sort=(size descending)
Example (Linux)
> d '***' -totals -sort=\(size descending\)
Options
Print a grand total for all the files in all the directories.
-totals Just print the total number of bytes for each directory.
-resolution [= size] Print directories and files that are bigger than a certain size. Directories that are smaller than the specified size will not be listed as entries of their own. Instead, the byte total will be added to the size of the parent directory.
-sort [= sort_order] Sorts the files by name (default), extension, size, or date.
-files List the full filenames only, without any information about file sizes or dates, and with no headers or footers. The output will be a list of file names that is suitable for use as input for other programs.
-header Print a header for each new directory that has files in it, and a footer with totals.
-size [= bytesize_syntax] Print the file sizes.
-date [= datetime_syntax] Print the date and time when each file was created.
-name [= filename_syntax] Specify how the file name should be printed (with or without full path, with or without extension, etc.).
-permissions Shows the file access permissions for each file.


These options control what output is produced, and how it is formatted. See Directory - Output Options.

Output File

Example (Windows and Linux)
> d -output=mydir.lis
Options
-output [= filename]
-o [= filename]
Specifies an output file. If the option is not present, output will be sent to standard output.

If the -output option is given without a filename, the default filename is a.tmp, in the current working directory.


See File Version Numbers: Output Files for a description of how the version numbers work for output files.

Help and Information Options

Example (Windows and Linux)
> d '*.log' -nowarning
Options
-help   -h   -?
Print out a brief help text with a summary of each of the different options, and exit from the program.
-version Show the name and version number of the program, and exit. This option must be written out in full, and cannot be abbreviated.
-verbose   -v
-statistics
-noverbose
Specify the amount of informational messages.
-warning
-nowarning
-noerror
Specify the level of error reporting.

See Help and Information Options.