> DOS 中文参考手册 > dir

DIR

(directory)


显示目录中的文件和子目录列表。

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename] 指定要列出的驱动器、目录和/或文件。

/A 显示具有指定属性的文件。

attributes D 目录 R 只读文件

H 隐藏文件 A 准备存档的文件

S 系统文件 - 表示“否”的前缀

/B 使用空格式(没有标题信息或摘要)。

/C 在文件大小中显示千位数分隔符。这是默认值。用 /-C 来停用分隔符显示。

/D 跟宽式相同,但文件是按栏分类列出的。

/L 用小写。

/N 新的长列表格式,其中文件名在最右边。

/O 用分类顺序列出文件。

sortorder N 按名称(字母顺序) S 按大小(从小到大)

E 按扩展名(字母顺序) D 按日期/时间(从先到后)

G 组目录优先 - 颠倒顺序的前缀

/P 在每个信息屏幕后暂停。

/Q 显示文件所有者。

/S 显示指定目录和所有子目录中的文件。

/T 控制显示或用来分类的时间字符域。

timefield C 创建时间

A 上次访问时间

W 上次写入的时间

/W 用宽列表格式。

/X 显示为非 8dot3 文件名产生的短名称。格式是 /N 的格式,短名称插在长名称前面。如果没有短名称,在其位置则显示空白。

/4 用四位数字显示年

可以在 DIRCMD 环境变量中预先设定开关。通过添加前缀 - (破折号)来替代预先设定的开关。例如,/-W。

★★★★★实例★★★★★:

假设要显示某一目录下的所有文件和目录,包括隐藏文件和系统文件,可使用下面命令:

dir /a

如果显示当前驱动器下所有目录,并依次列表,同时对于每个目录列表按横显格式,并按字母顺序排序,而且一次屏,则可在根目录下使用下面命令:

dir /s/w/o/p

DIR列出了根目录名,根目录下子目录名,以及根目下的所有文件名,然后以目录树的形式列出了子目录名和子目录下所有文件名。

可改变上一例子,使得DIR显示文件名和扩展名,但忽略目录名,命令如下:

dir /s/w/o/p/a:-d

为打印目录列表,可在任何DIR命令之后,给出重定向符和PRN,例如:

dir > prn

当在DIR命令行指明了PRN,则目录列表被送到连接在端口LPT1的打印机上。如果打印机所连接的是其它的端口,你必须用该端口名称来替代PRN。

亦可重新定向输出到一文件,只须用一文件名替代PRN。 在命令行同样可以给出路径,例如,定向DIR的输出到RECORDS目录下的DIR.DOC文件中,可使用下面命令:

dir > \records\dir.doc

如果DIR.DOC文件不存在,MS-DOS将创建它,除非目录RECORDS也不存在,这时,MS-DOS将显示下面的信息:

File creation error

若要显示驱动器C的所有目录中扩展名为.TXT的文件,可使用下面命令:

dir c:\*.txt /w/o/s/p

DIR将按横显格式,字母顺序,且每次只显示一屏。


Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

[drive:][path][filename] Specifies drive, directory, and/or files to list.

/A Displays files with specified attributes.

attributes D Directories R Read-only files

H Hidden files A Files ready for archiving

S System files - Prefix meaning not

/B Uses bare format (no heading information or summary).

/C Display the thousand separator in file sizes. This is the default. Use /-C to disable display of separator.

/D Same as wide but files are list sorted by column.

/L Uses lowercase.

/N New long list format where filenames are on the far right.

/O List by files in sorted order.

sortorder N By name (alphabetic) S By size (smallest first)

E By extension (alphabetic) D By date/time (oldest first)

G Group directories first - Prefix to reverse order

/P Pauses after each screenful of information.

/Q Display the owner of the file.

/S Displays files in specified directory and all subdirectories.

/T Controls which time field displayed or used for sorting

timefield C Creation

A Last Access

W Last Written

/W Uses wide list format.

/X This displays the short names generated for non-8dot3 file names. The format is that of /N with the short name inserted before the long name. If no short name is present, blanks are displayed in its place.

/4 Displays four-digit years

Switches may be preset in the DIRCMD environment variable. Override preset switches by prefixing any switch with - (hyphen)--for example, /-W.


上一篇:
下一篇: