DIR

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

This command displays the files and subdirectories that a directory contains.

DIR [path][file_name][/P][/W][/A[[:]atrributes]][/O[[:]sort_order]]
    [/T[[:]time_field]][/S][/B][/L]

Parameters

  • path
    Specifies that path of the directory for which you want to display files and subdirectories.
  • file_name
    Specifies the files that you want to display.
  • /P
    Displays only one screen of information at a time. To see the next screen, press any key on the keyboard.
  • /W
    Displays the list of files in a wide format, with as many as five file names or directory names on each line.
  • /A
    Displays only the files with the attributes that the attributes parameter specifies.
  • attributes
    Specifies the attributes that you want to use to limit the list of the files that the DIR command displays. The following table shows the possible values.

    Value Description

    A

    Displays only files with the archive attribute set.

    -A

    Displays only files that do not have the archive attribute set.

    D

    Displays only directories.

    -D

    Displays files, but not directories.

    H

    Displays only files that are hidden.

    -H

    Displays only files that are not hidden.

    R

    Displays only read-only files.

    -R

    Displays only files that are not read-only.

    S

    Displays only system files.

    -S

    Displays only files that are not system files.

  • /O
    Sorts the files base on the value of the sort_order parameter.
  • sort_order
    Specifies the value that you want to use for sorting the files. The following table shows the possible values.

    Value Description

    D

    Sorts files by date, with the earliest file first.

    -D

    Sorts files by date, with the earliest file last.

    E

    Sorts files in alphabetical order by file extension.

    -E

    Sorts files in reverse alphabetical order by file extension.

    G

    Displays directories in a group before files.

    -G

    Displays directories in a group after files.

    N

    Sorts files alphabetically by name.

    -N

    Sorts files in reverse alphabetical order by name.

    S

    Sorts files by size, with the smallest file first.

    -S

    Sorts files by size, with the smallest file last.

  • /T
    Indicates that the DIR command you use the value of the time_field parameter to determine the time used when displaying and sorting the list of files.
  • time_field
    Specifies the time field to use when displaying and sorting the list of files. The following table shows the possible values.

    Value Description

    A

    Uses the time the file was last accessed.

    C

    Uses the time the file was created.

    W

    Uses the time the file was last written.

  • /S
    Displays the contents of subdirectories recursively.
  • /B
    Lists each directory name or file name, one per line, including the file name extension. /B does not display heading information or a summary. /B overrides /W.
  • /L
    Displays file names with lowercase characters.

See Also

Reference

Command Processor Commands

Concepts

Command Processor Shell