dir (命令)

✍ dations ◷ 2024-12-22 18:46:27 #Windows命令,内部DOS命令,Windows管理,文件系统目录

dir (directory,目录)是一个条列档案及目录的命令行界面指令,在CP/M、VMS、DOS、OS/2、Singularity及Microsoft Windows等操作系统中都有此指令。

dir指令基本上会会列出目录中的档案及子目录的名称,也可以列出其档案大小,建立时间等相关资讯,并且列出所在的磁盘机、可用空间等资讯。dir指令也可以寻找其档案名称符合特定条件的档案。

以下的范例是在Windows 7中给dir指令,没有指令列引数时的输出:

 C:\Users\Public\Pictures\Sample Pictures>dir  Volume in drive C is System  Volume Serial Number is C8D0-76E2   Directory of C:\Users\Public\Pictures\Sample Pictures  14-07-2009  06:41    <DIR>          . 14-07-2009  06:41    <DIR>          .. 14-07-2009  06:52           879,394 Chrysanthemum.jpg 14-07-2009  06:52           845,941 Desert.jpg 14-07-2009  06:52           595,284 Hydrangeas.jpg 14-07-2009  06:52           775,702 Jellyfish.jpg 14-07-2009  06:52           780,831 Koala.jpg 14-07-2009  06:52           561,276 Lighthouse.jpg 14-07-2009  06:52           777,835 Penguins.jpg 14-07-2009  06:52           620,888 Tulips.jpg                8 File(s)      5,837,151 bytes                2 Dir(s)  57,925,980,160 bytes free  C:\Users\Public\Pictures\Sample Pictures>dir /w  Volume in drive C is System  Volume Serial Number is C8D0-76E2   Directory of C:\Users\Public\Pictures\Sample Pictures                                   Chrysanthemum.jpg   Desert.jpg          Hydrangeas.jpg      Jellyfish.jpg Koala.jpg           Lighthouse.jpg      Penguins.jpg        Tulips.jpg                8 File(s)      5,837,151 bytes                2 Dir(s)  57,925,992,448 bytes free  C:\Users\Public\Pictures\Sample Pictures>

选项及指令列引数

以下是Microsoft Windows下,dir指令的选项及指令列引数

 DIR  attributes]]       sortorder]]     timefield]]                   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               I  Not content indexed files               L  Reparse Points             -  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.  /R          Display alternate data streams 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              name inserted before the long name.  If no short name is present, blanks are displayed in its place.  /4          Displays four-digit years.

选项可以放在DIRCMD环境变数中,若要关闭现有的设定,可以在选项前加上-,例如/-W。

dir不是Unix指令,Unix有类似的指令ls,不过GNU/Linux操作系统中有dir指令,等效于ls -C -b

相关