dir列出⽂件清单_WindowsDir命令教程,以列出⽂件和⽂件信
息的⽰例
dir 列出⽂件清单
Dir command is one of the most used Windows commands. Dir is used mainly to list files and directories in Windows operating systems. In this tutorial, we will look at different usage examples of the dir command.
Dir命令是最常⽤的Windows命令之⼀。 Dir主要⽤于列出Windows操作系统中的⽂件和⽬录。 在本教程中,我们将查看dir命令的不同⽤法⽰例。
列出⽂件和⽂件夹 (List Files and Folders)
Without providing any option and parameter we will list all files and folders in the current working path. The current working path is the path where the shell currently locates. While printing files and folders there is also information like Volume name and Volume Serial Number.
在不提供任何选项和参数的情况下,我们将列出当前⼯作路径中的所有⽂件和⽂件夹。 当前⼯作路径是外壳当前所在的路径。 在打印⽂件和⽂件夹时,还有诸如卷名和卷序列号之类的信息。
$ dir
List Files and Folders
列出⽂件和⽂件夹
列出⽂件和⽂件夹的裸格式(List Files and Folders Bare Format)
The bare format will only provide files and folders. There will be no other information like creation date-time file type etc. We will provide the /b option.
裸格式将仅提供⽂件和⽂件夹。 将没有其他信息,例如创建⽇期时间⽂件类型等。我们将提供/b选项。
$ dir /b
List Files and Folders Bare Format
列出⽂件和⽂件夹的裸格式
递归列出⽂件(List Files Recursively)
The default behavior is listing only the current working directory. Listing subdirectories is a need some times. This can be done with /s option like below.
默认⾏为是仅列出当前⼯作⽬录。 列出⼦⽬录有时是需要的。 可以使⽤/s选项(如下所⽰)完成此操作。
$ dir /s
根据扩展名列出⽂件 (List Files According To Extension)
Another useful feature is listing files and directories with regular expressions or similar glob presentations. One of the most used wanted situations is listing files and folders according to their extension. In this example, we will list txt extension by using wildcard.
另⼀个有⽤的功能是使⽤正则表达式或类似的glob表⽰形式列出⽂件和⽬录。 最常⽤的通缉情况之⼀是根据⽂件和⽂件夹的扩展名列出它们。 在此⽰例中,我们将使⽤通配符列出txt扩展名。
$ dir *.txt
List Files According To Extension
根据扩展名列出⽂件
列出JPEG⽂件(List JPEG Files)
We can list jpeg files with the following command.
我们可以使⽤以下命令列出jpeg⽂件。
$ dir *.jpeg
列出Excel(xls)⽂件 (List Excel (xls) Files)
We can list Excel files with the following command.
我们可以使⽤以下命令列出Excel⽂件。
$ dir *.xls
列出Word(doc)⽂件 (List Word (doc) Files)
We can list Word files with the following command.
我们可以使⽤以下命令列出Word⽂件。
$ dir *.doc
⽂件和⽂件夹属性 (File and Folder Attributes)
Files and folder have attributes to provide information and store metadata about them. These attributes can be listed with dir command by providing related options. Some attributes file and folder may have are listed below;
⽂件和⽂件夹具有提供信息并存储有关它们的元数据的属性。 通过提供相关选项,可以使⽤dir命令列出这些属性。 下⾯列出了⼀些属性⽂件和⽂件夹:
Read
Write
Hidden
Directory
⽬录
了解更多信息如何在Linux Bash中循环⽂件?
仅列出⽬录 (List Only Directories)
We may need to print only directories and do not include files. This can be done with the display only directory attribute like below.
我们可能只需要打印⽬录⽽不包含⽂件。 这可以通过如下所⽰的“仅显⽰⽬录”属性来完成。
$ dir /A:D
List Only Directories
仅列出⽬录
仅列出⽂件(List Only Files)
We will use directory attribute but we will negate the attribute and this will only display the non directory files. We will use /A:-D option .
我们将使⽤⽬录属性,但是将使属性⽆效,这将仅显⽰⾮⽬录⽂件。 我们将使⽤/A:-D选项。
$ dir /A:-D
List Only Files
仅列出⽂件
linux查看当前路径命令列出只读⽂件(List Read Only Files)
In windows systems, files can be read, write, append, etc. To protect files for changes some files are made read-only. These files can be listed by using read-only attributes with /A:R.
在Windows系统中,可以读取,写⼊,追加等⽂件。为了保护⽂件不被更改,某些⽂件被设为只读。 可以通过对/A:R使⽤只读属性来列出这些⽂件。
$ dir /A:R
列出隐藏⽂件 (List Hidden Files)
Hidden files can be listed with the /A:H option.
可以使⽤/A:H选项列出隐藏的⽂件。
$dir /A:H
排除只读⽂件 (Exclude Read Only Files)
Read only files can be excluded by negating the normal usage like below.
通过取消如下所⽰的常规⽤法,可以排除只读⽂件。
$ dir /A:-R
排除系统⽂件 (Excludes System Files)
Windows have system files that have tagged as system files as an attribute. We can exclude system files while listing with
/A:-S.
Windows具有标记为系统⽂件作为属性的系统⽂件。 当使⽤/A:-S列出时,我们可以排除系统⽂件。
$ dir /A:-S
打印⽂件的详细元数据 (Print Detailed Metadata For Files)
Meta data about files and folder can be printed with /Q option. This will also list file ownership.可以使⽤/Q选项打印有关⽂件和⽂件夹的元数据。 这还将列出⽂件所有权。
$ dir /Q
Print Detailed Metadata For Files
打印⽂件的详细元数据
列出⽂件和⽂件夹的创建时间(List Create Time of Files and Folders)
The file creation time can be listed with the /TC option.
可以使⽤/TC选项列出⽂件创建时间。
$ dir /TC
List Created Time
列出创建时间
列出上次访问时间(List Last Accessed Time)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。