Purpose:Display information about files and subdirectories in user-definable fields. It is a "programmable DIR" command.

 

Format:PDIR [ranges] [/\ /A:[attrlist] /B CD:text /D /H /HL /I"text" /K /M /N[defhjlsvz] /O:[order] /P[n] /Q /S[[+]n] /T:t /(...)] [file...]

 

attrlistSelection attributes (see attribute switches for details)
orderHierarchical list of sort keys
rangesOne or more date, description, exclusion, size, time ranges
fileOne or more files to list
tTimestamp type selection code

 

/A:

Attribute select

/M

show footer

/B

Bare filenames

/N

Disable options

/CD:...

COLORDIR string

/O

Order

/D

colorize

/P

Page pause

/H

do not Hide . and ..

/Q

Owner name

/HL

Hard links

/S

Subdirectories

/I"text"

description range

/T[:t]

Timestamp type

/K

show header

/(...)

output fields and format

 

See also: DIR, ATTRIB, DESCRIBE, and SELECT.

 

File Selection

 

Supports attribute switches, extended wildcards, ranges, multiple file names, and include lists.

 

Internet

 

Can be used with FTP/HTTP Servers.

 

Usage

 

PDIR is an extremely flexible command allowing you to display information about files and directories from one or more local or remote volume or directories in a wide array of user-defined formats. For a simpler version, see the DIR command.

 

PDIR and DIR are related, but they do not have identical switches and they are not intended to produce identical output. PDIR is primarily intended to produce output that will be subsequently parsed by another program (or batch file), or (more rarely) for a special-purpose directory display. Its options and output are geared towards those applications.

 

The various PDIR displays are controlled through options or switches. The best way to learn how to use the many options available with the PDIR command is to experiment. You will soon know which options you want to use regularly. You can then select those options permanently by using the ALIAS command.

 

The /(...) option specifies which fields you want to display and how to format them. (You can have multiple /(...) options on a line.)  The syntax is:

 

aAttributes

 

cCompression:  Display the compression percentage on NTFS drives with compression enabled.

 

d[...] Date (you must specify at least one subfield, otherwise the field remains blank)
dday (2 digits, leading zero)
mmonth (2 digits, leading zero)
yyear (4 digits)

 

f[...]File or Directory name (case sensitive)
PSFN path
pLFN path
NSFN filename
nLFN filename (default)
qEnclose the filename in double quotes if it contains whitespace or special characters

 

iDescription

 

kCKSUM hash value (see the @CKSUM function)

 

mMD5 hash value (see the @MD5 function)

 

qFile or directory owner (NTFS only)

 

rCRC32 hash value (see the @CRC32 function)

 

sstream names (NTFS only)

 

sppath and stream names as pathname+filename+streamname (NTFS only)

 

t[...]Time (you must specify at least one subfield, otherwise the field remains blank)
hhours (2 digits, leading zero)
mminutes (2 digits, leading zero)
sseconds (2 digits, leading zero)
dmilliseconds (decimal separator and 3 digits)
z[...]Size
aAllocated size (this will usually be more than the physical size unless the file is compressed.) Note that you cannot get the allocated size on FTP servers or network sharenames.
cThe size will be formatted using the thousands separator (default is a  comma)
k|K|m|M|g|G|t|T(case sensitive)  format as kilobytes, megabytes, gigabytes, or terabytes, as used in variable functions (see Memory Size / Disk Space / File Size Units and Report Format). Note that the size will be truncated, not rounded.

 

@function[*]

call the specified variable function (internal or user-defined). To specify the current filename, use * as the  parameter. For example, pdir /(f @md5[*]) displays the filename and the MD5 hash. Note that the % prefix of the function name is NOT used with the symbolic * parameter. If the parameter of the function is not the symbolic * or it is an "inner" function the % prefix must be doubled, e.g., @function1[%%@function2[*]]

 

"..."Literal string (in quotes). Characters are displayed as is, except that escape characters are converted.

 

You can also specify a format, independently for each field, by prefixing the field character with its format specification:

 
[-]i.a

 

where

 -        specifies left justification instead of the default, right justification;

 i        specifies the minimum field width, and

 a        specifies the maximum field width.

 

If the first digit of i is 0, the field will be padded with zeros instead of spaces. Some fields cannot be reduced below a minimum width (for example, the z (size) field is a minimum of 15 digits).

 

If a PDIR line is empty (for example, if you have an embedded @IF), it will not be displayed.

 

If you want to append fields with no intervening whitespace, or with a custom delimiter character, you can use double quotes to specify arguments. For example, to display the date and time with no space between them:

 

pdir /(dymd""thms) *

 

Or to display the date and time separated by a +:

 

pdir /(dymd"+"thms) *

 

PDIR sets three internal variables:

 

%_pdir_dirsThe number of directories created
%_pdir_filesThe number of files moved
%_pdir_errorsThe number of errors

 

Example

 

To display the CRC, the full LFN and the owner  of each file:

 

pdir /(r fpn q) *

 

Options:

 

Options on the command line apply only to the filenames which follow the option, and options at the end of the line apply to the preceding filename only. This allows you to specify different options for different groups of files, yet retains compatibility with the traditional DIR command when a single filename is specified.

 

Most options are used to select the desired files/directories. (This is in contrast to the DIR command.) The special option /(...) is used to specify which characteristics of the selected files or directories should be displayed in which sequence and format.

 

/\Display directory names with a trailing \.

 

/A:...Display only those files that have the specified attribute(s) set. See Attribute Switches for information on the attributes which can follow /A:.

 

You can specify /A:= to display a dialog to help you set individual attributes.

 

/BSuppress the header and summary lines, and display file or subdirectory names only, in a single column. This option is most useful when you want to redirect a list of names to a file or another program. If you use /B with /S, PDIR will show the full path of each file instead of simply its name and extension. If you use /B with /X on an LFN drive, PDIR will display the short name of each file instead of the long name. /B also sets /H.

 

/B1 will display relative paths when used with /S. (Normally, /B shows the full pathname for the file.)

 

/CD:Define a custom directory colorization string to use instead of the COLORDIR environment variable, or the ColorDir option in TCMD.INI.

 

/DDon't colorize the directory listing. See DIR for more information on directory colorization.

 

/HShow the "." and ".." directory names (normally suppressed).

 

/HLShow hard links.

 

/I"text"Select filenames by matching text in their descriptions. See Description Ranges for details.

 

/KShow the header (disk and directory name) display.

 

/MShow the footer (file and byte count totals) display.

 

/NTurn off the specified options.

 

dSkip hidden directories (when used with /S)
eDon't display errors
fSuppress bytes free in the footer
hSuppress the header
jSkip junctions (when used with /S)
lDon't display link name for symbolic links
m:nDisplay a maximum of n directory entries
sSuppress the footer
vSuppress the volume label in the header
zSkip system directories (when used with /S)

 

/O...The sorting order is applied to the listings of each subdirectory separately. Any combination of the sorting options may be used. If multiple options are specified, the listing will be sorted with the first sort option as the primary key, the next as the secondary key, and so on.

 

nSort by filename and extension (default). If e is also specified, sort by name only.
-Reverse the sort order for the next option
aSort names and extensions in standard ASCII order, rather than sorting numerically when digits are included in the name or extension.
cSort by compression ratio (the least compressed file in the list will be displayed first).
dSort by date and time (oldest first); also see /T:acw
eSort by extension
gGroup subdirectories first, then files
iSort by file description (ignored if /C or /O:c is also used).
oSort by owner
rReverse the sort order for all options
sSort by size
tSame as d
uUnsorted
xWhen combined with /S, sorts the results from all directories together and displays them in a single listing. Note that /O:x will turn off headers and footers.

 

/P[n]Wait for a key to be pressed after each screen page before continuing the display. Your options at the prompt are explained in detail under Page and File Prompts. The /P option has an optional argument n that specifies the number of seconds to wait for a keystroke before continuing.

 

/QShow the owner of the file.

 

/SDisplay file information from the current directory and all of its accessible subdirectories.

 

If you specify a number after the /S, PDIR will limit the subdirectory recursion to that number. For example, if you have a directory tree "\a\b\c\d\e", /S2 will only affect the "a", "b", and "c" directories.

 

If you specify a + followed by a number after the /S, PDIR will not display any filenames until it gets to that depth in the subdirectory tree. For example, if you have a directory tree \a\b\c\d\e, /S+2 will not display the contents of \a or \a\b.

 

/T:type Specifies which single one of the date and time fields below, available on a drive which supports long filenames, should be displayed and used for sorting:

 

aLast access date and time (NTFS volumes).
cCreation date and time.
wLast write date and time (default).

 

If /T is not specified, the default is /T:w.

 

If you append a u after the field, DIR will display the file time in UTC.

 

Note: If more than one time type is specified, the first one specified is used, and all subsequent ones ignored.

 

/(...)Use this option to define the various fields and display formats you wish to use for each selected entry. The fields may be in any order, and may be repeated. If this option is not used, the output format is identical to that of the DIR command. If you specify multiple /(...) options, PDIR will insert a space in the output between each one.