DOS中的dir命令的参数

DOS中的dir命令的参数

2023年7月3日发(作者:)

DOS中的dir命令的参数显⽰⽬录⽂件和⼦⽬录列表。如果在没有参数的情况下使⽤,则 dir 显⽰磁盘的卷标和序列号,后接磁盘上⽬录和⽂件的列表,包括它们的名称和最近修改的⽇期及时间。dir 可以显⽰⽂件的扩展名以及⽂件的字节⼤⼩。Dir 也显⽰列出的⽂件及⽬录的总数、累计⼤⼩和磁盘上保留的可⽤空间(以字节为单位)。MS-DOS命令语法dir [Drive:][Path][FileName] […] [/p] [/q] [/w] [/d] [/a[[:]attributes]][/o[[:]SortOrder]] [/t[[:]TimeField]] [/s] [/b] [/l] [/n] [/x][/c] [/4]MS-DOS命令参数[Drive:][Dath]指定要查看列表的驱动器和⽬录。[FileName]指定要查看列表的特定⽂件或⼀组⽂件。/p每次显⽰⼀个列表屏幕。要查看下⼀屏,请按键盘上的任意键。/q显⽰⽂件所有权信息。/w以宽格式显⽰列表,在每⼀⾏上最多显⽰ 5 个⽂件名或⽬录名。/d与 /w 相同,但是⽂件按列排序。/a[[:]attributes]只显⽰那些指定属性的⽬录和⽂件名称。如果省略 /a,dir 将显⽰除隐藏⽂件和系统⽂件之外的所有⽂件名。如果在没有指定 attributes的情况下使⽤ /a,dir 显⽰所有⽂件的名称,包括隐藏⽂件和系统⽂件。以下列表描述了每个可⽤于 attributes 的值。冒号 (? 是可选的。使⽤这些值的组合,并且不得⽤空格分隔这些值。值hsdar-h-s/d-a-r说明隐藏⽂件系统⽂件⽬录准备好存档的⽂件只读⽂件⾮隐藏的⽂件系统⽂件以外的⽂件只是⽂件(⽽⾮⽬录)⾃上次备份后没有更改过的⽂件⾮只读的⽂件/o [[:]SortOrder]控制 dir 排序和显⽰⽬录名和⽂件名的顺序。如果省略 /o,dir 将按它们在⽬录中出现的顺序显⽰名称。如果在没有指定 SortOrder 的情况下使⽤ /o,dir 显⽰按字母顺序排列的⽬录名,然后显⽰按字母顺序排列的⽂件名。冒号 (? 是可选的。以下列表描述了每个可⽤于SortOrder 的值。使⽤这些值的任意组合,并不要⽤空格分隔这些值。值说明ne按名称的字母顺序按扩展名的字母顺序d值sg-n-e/d-s-g按⽇期和时间,最早的优先。说明按⼤⼩,最⼩的优先在⽂件之前分组的⽬录按名称的逆序字母(从Z 到 A)排序按扩展名的逆序字母(从.ZZZ 到 .AAA)排序按⽇期和时间,最晚的优先按⼤⼩,最⼤的优先在⽂件之后分组的⽬录/t [[:]TimeField]指定显⽰或⽤于排序的时间字段。以下列表描述了每个可⽤于 TimeField 的值。值caw说明创建上次访问上次写⼊/s列出指定⽬录及所有⼦⽬录中出现的每个指定的⽂件名。/b列出每个⽬录名或⽂件名,每⾏⼀个(包含⽂件扩展名)。/b 不显⽰标题信息或摘要。/b 替代 /w。/l按⼩写字母显⽰未排序的⽬录名和⽂件名。/l 不会将扩展字符转换为⼩写字符。/n显⽰长列表格式,⽂件名在屏幕最右边。/x显⽰ NTFS 和 FAT 卷上⽂件⽣成的短名称。显⽰与 /n 的显⽰相同,但是短名称显⽰在长名称之后。/c按⽂件⼤⼩显⽰多个分隔符。/4显⽰四位数字的年份格式。/?在命令提⽰符显⽰帮助。MS-DOS命令注释使⽤多个filenames可以使⽤多个filenames。⽤空格、逗号或分号分开⽂件名。可以在 FileName中使⽤通配符(? 和 *)以显⽰⼀组⽂件。使⽤通配符可以使⽤通配符(? 和 *)显⽰⽂件和⼦⽬录的⼦集列表。指定⽂件显⽰属性如果使⽤ /a,并且 attributes中指定多个值,dir 只显⽰那些包含所有指定属性的⽂件的名称。例如,如果利⽤ /a:r-h 或 /ar-h 指定 /a ,并以值 r 和 -h 作为属性,则 dir 将只显⽰⾮隐藏的只读⽂件的名称。指定⽂件名排序如果指定了多个 SortOrder 值,dir ⾸先通过第⼀个标准对⽂件名进⾏排序,然后再通过第⼆个标准排序,等等。例如,如果使⽤ /o:e-s 或 /oe-s 指定了 /o 以及 SortOrder 的值 e 和 -s,则 dir 将根据扩展名对⽬录名和⽂件名从⼤到⼩进⾏排序,然后显⽰最终结果。扩展名按照字母排序使得没有扩展名的⽂件名最先显⽰,⽬录名次之,然后是具有扩展名的⽂件名。使⽤重定向符号和管道在使⽤重定向符号 (>) 将 dir 输出发送到⽂件,或者使⽤管道 (|) 将 dir 输出发送到其它命令时,请使⽤ /a:-d 和 /b 只列出⽂件名。可以使⽤ FileName 以及/b 和 /s 来指定 dir 在当前⽬录及其⼦⽬录中搜索所有匹配 FileName 的⽂件名。Dir 对查找的每个⽂件名只列出驱动器号、⽬录名、⽂件名和⽂件扩展名、每⾏⼀个路径。在使⽤管道重定向之前,应该在 ⽂件中设置 TEMP 环境变量。预先设置 dir 参数通过将 set 命令包含在 中的 DIRCMD 环境变量中,可以预置 dir 参数。可以使⽤ dir 参数和 set dircmd 的任意有效组合,其中包含⽂件的位置和名称。例如,要使⽤ DIRCMD 环境变量将宽⾏显⽰格式 (/w) 设置为默认格式,必须在您的 ⽂件中键⼊以下命令:set dircmd=/w要单独使⽤ dir 命令,您可⽤ DIRCMD 环境变量替代参数。为此,请在 dir 命令提⽰符下键⼊要替代的参数(参数前⾯带上减号)。例如:dir /-w要更改 DIRCMD 默认设置,请键⼊:set=NewParameter新的默认设置对所有后接的 dir 命令有效,直到再次使⽤ set dircmd 或直到重新启动计算机。要清除所有默认设置,请键⼊:set dircmd=要查看 DIRCMD 环境变量的当前设置,请键⼊:setSet 显⽰环境变量及其设置的列表。有关设置环境变量的详细信息,请参阅“相关主题”。从“故障恢复控制台”可以使⽤包含各种参数的 dir 命令。MS-DOS命令范例要按字母顺序以宽格式⼀个接⼀个地显⽰所有⽬录,并在显⽰出每个屏幕后暂停⼀下,必须确保根⽬录是当前⽬录,然后键⼊:dir /s/w/o/pDir 列出根⽬录的名称、根⽬录的⼦⽬录名称和根⽬录中⽂件的名称(包括扩展名)。然后 dir 在⽬录树中的每个⼦⽬录中列出⼦⽬录名和⽂件名。要更改前⾯的范例以便 dir 显⽰⽂件名和扩展名但省略⽬录名,请键⼊:dir /s/w/o/p/a:-d要打印⽬录列表,请键⼊:ir > prn指定 prn 时,⽬录列表发送到连接 LPT1 端⼝的打印机。如果打印机被连接到不同的端⼝,则必须使⽤正确端⼝的名称替换 prn。也可以通过⽤⽂件名替换 prn,将 dir 命令的输出重定向到⽂件。还可以键⼊路径。例如,要将 dir 的输出结果定向到 Records ⽬录中的 ⽂件中,可以键⼊:dir > /records/如果 不存在,dir 将创建该⽂件,除⾮ Records ⽬录也不存在。在这种情况下,会出现如下消息:File creation error要显⽰驱动器 C 上所有⽬录中带 .txt 扩展名的所有⽂件名的列表,请键⼊:dir c:/*.txt /w/o/s/pdir 命令以宽度格式并按字母顺序显⽰每个⽬录中匹配⽂件名的列表,⽽且每次满屏时暂停,直到您按键继续。About dirThe dir command allows you to see the available files in a bilityThe dir command is an internal command and is available in the below Microsoft operating versions of MS-DOSWindows 95Windows 98Windows MEWindows NTWindows 2000Windows XPWindows VistaWindows 7SyntaxMicrosoft Windows 95, 98, and ME syntaxDisplays a list of files and subdirectories in a [drive:][path][filename] [/P] [/W] [/A[[:]attributes]] [/O[[:]sortorder]] [/S] [/B] [/L] [/V][drive:][path][filename] Specifies drive, directory, or files to list. (Could be enhanced file specification or multiple filespecs.)/P Pauses after each screenful of information./W Uses wide list format./A attributes:D DirectoriesR Read-only filesH Hidden filesA Files ready for archivingS System filesPrefix meaning not/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 (earliest first)G Group directories firstPrefix to reverse orderA By Last Access Date (earliest first)/S Displays files in specified directory and all subdirectories./B Uses bare format (no heading information or summary)./L Uses lowercase./V Verbose es may be preset in the DIRCMD environment variable. Override preset switches by prefixing any switch with -(hyphen)–for example, /-oft Windows 2000 and Windows XP syntaxDisplays a list of files and subdirectories in a [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, or files to utesD 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 derN By name (alphabetic) S By size (smallest first) E By extension (alphabetic) D By date/time (oldest first) G Groupdirectories 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 Control what time field displayed or used for sortingtimefield C CreationA Last AccessW 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 insertedbefore the long name. If no short name is present, blanks are displayed in its place./4 Displays four-digit yearsExamplesdirLists all files and directories in the directory that you are currently *.exeThe above command lists any executable file or any file that ends with .exe. See the wildcard definition for further /adList only the directories in the current directory. If you need to move into one of the directories listed use the cd /sLists the files in the directory that you are in and all sub directories after that directory, if you are at root “C:/>” and typethis command this will list to you every file and directory on the C: drive of the /pIf the directory has a lot of files and you cannot read all the files as they scroll by, you can use this command and it willdisplay all files one page at a /wIf you don’t need the info on the date / time and other information on the files, you can use this command to list just thefiles and directories going horizontally, taking as little as space /s /w /pThis would list all the files and directories in the current directory and the sub directories after that, in wide format and onepage at a /onList the files in alphabetical order by the names of the /o-nList the files in reverse alphabetical order by the names of the / /s |find “i” |moreA nice command to list all directories on the hard drive, one screen page at a time, and see the number of files in eachdirectory and the amount of space each > es the output of dir and re-routes it to the file instead of outputting it to the /b /s *.jpg >file_

发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1688382184a129618.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信