dir 列出文件清单_Windows Dir命令教程,以列出文件和文件信息的示例

dir 列出文件清单

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
列出文件和文件夹

列出文件和文件夹的裸格式(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 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
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

    目录
LEARN MORE  How To Linux Bash For Loop In Files?
了解更多信息如何在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 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
List Only Files
仅列出文件

列出只读文件(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
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 Created Time
列出创建时间

列出上次访问时间(List Last Accessed Time)

Files are accessed during time these access time can be printed with the /TA option like below.

在访问期间,可以使用/ TA选项打印这些访问时间,如下所示。

$ dir /TA
List Last Accessed Time
List Last Accessed Time
列出上次访问时间

查找上次修改时间(Find Last Modified Time)

Last modified time of the file can be listed with the /TW option.

文件的上次修改时间可以使用/ TW选项列出。

$ dir /TW
Find Last Modified Time
Find Last Modified Time
查找上次修改时间

翻译自: https://www.poftut.com/windows-dir-command-tutorial-examples-list-files-file-information/

dir 列出文件清单

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值