List all files in dir windows

Last Updated :
06 Mar, 2025

Struggling to find or organize files buried in folders on your Windows PC? While File Explorer offers a visual way to browse, the Command Prompt (CMD) provides a faster, more powerful method to list, sort, and manage files, especially when dealing with large directories or automating tasks.

In this quick guide on how to list all files in a directory using CMD in Windows, you will explore how to use simple CMD commands like dir to instantly display every file and subfolder in any directory. We’ll break down the syntax, explain how to filter results (by name, date, or type), and share tricks to export lists for backups.

Prerequisites to Access Directory in Win

  • Windows PC (11, 10, 8 or 7)
  • Administrator Rights
  • Familiar with Command Prompt actions (or knowing how to open it, i.e. Win + R & type CMD)

What Command Can Be Used to List Files

The «dir» command is fundamental in the Windows Command Prompt, which is used to list the contents of a directory. Here’s a bit more detail on how it works.

1. Basic Usage

  • When you type dir and press Enter in the Command Prompt, it lists all the files and directories in the current directory.
  • By default, it displays the file name, size, and modification date and time.

2. Options

  • /A: This option displays files with specified attributes. For example, /A: H displays hidden files.
  • /B: Uses a bare format with no heading information or summary. It simply lists the names of files and directories.
  • /O: Specifies the order in which files are sorted. For instance, /O: N sorts files by name.
  • /S: Displays files in the specified directory and all subdirectories.
  • /P: Pauses after each screenful of information.
  • /W: Uses wide list format, displaying as many as five file names in each row.

3. Example Usage

  • dir /A: Lists all files including hidden files in the current directory.
  • dir /B: Displays a bare list of files and directories without any additional information.
  • dir /O:N: Sorts files by name.
  • dir /S: Lists files in the specified directory and all subdirectories.

How to List All Files in a Directory

Now, we will be discussing 4 basic steps to list all files in a directory using the Command Prompt. Let’s check them out:

Step 1: Open Command Prompt

  • First things first, let’s open the Command Prompt. You can do this by searching for «Command Prompt» in the Start menu or by pressing the Win + R keys, typing «cmd» in the «Run» dialog, and hitting Enter.
list-all-files-in-a-directory

Open Command Prompt

Step 2: Navigate to the Directory

  • Once you have the Command Prompt open, you need to navigate to the directory whose files you want to list. To do this, use the cd command followed by the path of the directory. For example, if you want to list files in a directory named «Documents» located in your user folder, you would type:
cd Documents

Press Enter after typing the command to change the directory.

Step 3: List Files

  • Now that you’re in the desired directory, it’s time to list all the files it contains. To do this, simply type the «dir» command and press Enter. This command displays a list of files and directories in the current directory.
List-Files

List Files

Step 4: Additional Options (Optional)

  • If you want to customize the way files are listed, you can use various options with the dir command. Here are some common options:
/A: Displays files with specified attributes.
/B: Uses bare format (no heading information or summary).
/O: Specifies the order in which files are sorted.
/S: Displays files in specified directory and all subdirectories.

For example, if you want to list all files including hidden files in bare format, you would type:

dir /A /B

Use Cases for Listing Files in CMD

  • IT Audits: Export a list of all .exe files in a directory for compliance checks.
  • Scripting Backups: Automate file logging with a batch script.
  • Troubleshooting: Identify missing or corrupted files in large folders.

CMD vs PowerShell: Which One to Use

Task CMD Command PowerShell Equivalent
List files dir Get-ChildItem
Filter by date dir /od Get-ChildItem | Sort LastWriteTime
Export to text file dir > output.txt Get-ChildItem > output.txt

Conclusion

Mastering the dir command in CMD lets you efficiently manage files, automate tasks and troubleshoot Windows system within a few steps. By following the outline steps, you can use the Command Prompt to organize your workspace or troubleshooting, without replying on graphical interfaces. Whether you’re an IT expert, a developer (for scripting batch jobs) or a casual user organizing personal documents, the ability to list files in a directory using CMD is a must-know job that everyone should know.

Also Read

  • CMD | Dir command
  • How to Delete a File or Folder Using CMD?
  • Search Files Faster on Windows 10 using Command Prompt

  • Home
  • Partition Magic
  • CMD List Files: How to List Files in Command Prompt Windows 10/11

By Ariel | Follow |
Last Updated

What command can be used to list files in a directory? How to list files in Command Prompt Windows 10/11? A great many people are confused about these questions. In this post, MiniTool explains the Command Prompt list files topic in detail and introduces an alternative to CMD list files.

CMD (Command Prompt) is a powerful Windows built-in tool that can be used to do many works such as CMD copy files, CMD list drives, CMD WiFi password, and more. However, a lot of users don’t how to list files in Command Prompt. Here’s a true example from the StackOverflow forum:

I tried searching for a command that could list all the files in a directory as well as subfolders using a command prompt command. I have read the help for the «dir» command but couldn’t find what I was looking for. Please help me with what command could get this.

https://stackoverflow.com/questions/15214486/command-to-list-all-files-in-a-folder-as-well-as-sub-folders-in-windows

Although there are already many discussions and posts about the Command Prompt list files, most of them lack clear steps and screenshots, which makes people difficult to understand the “CMD list files” operation. Thus, we want to write a complete guide to explain it. Let’s keep reading.

What Command Can Be Used to List Files

To list directory CMD smoothly, you need to know what command can be used to list files in a directory Windows first. The answer is to use the DIR command. This command can be used to show all files and subfolders in the current directory. In addition, it displays the file name, size, and last modification date of each file like File Explorer.

The DIR command is available in CMD for almost all Windows systems, including Windows 11/10/8/7/Vista/XP. Here are the most commonly used command lines about the CMD list directory/files:

  • D: List all directories in the current path
  • R: Show read-only files
  • H: Show hidden files
  • A: Archive files
  • S: List system files
  • I: Not content indexed files
  • L: Reparse points
  • -: Add a minus in front of any of the file attribute to let the DIR command not show that kind of file.

How to List Files in Command Prompt Windows 10/11

How to list files in CMD Windows 10/11? The answer depends on what files you want to list. Here we summarize several common examples of the Windows Command Prompt list files.

Step 1. First of all, you need to navigate to the directory in which you want to list files in File Explorer.

Step 2. Click on the address bar and type cmd in the file path and hit Enter, which will open the Command Prompt window.

Tips:

Also, you can locate the directory first in File Explorer, and then press the Win + R keys to open the Run box, type cmd in it, and hit Enter to open the Command Prompt window.

type cmd in the address bar of File Explorer

Step 3. In the pop-up window, you can list file CMD according to your needs. For example:

Example 1. CMD List all directories and folders under the current path.

dir

run dir in the cmd

Example 2. CMD List folders of the current directory only.

dir /ad

run dir ad

Example 3. CMD list files only under the directory.

dir /a-d

cmd list files only

Example 4. CMD list files and folders under a specific directory (e.g. C:Usersdefaultuser1)

cd C:Usersdefaultuser1

dir

CMD list files of a specific directory

Example 5. CMD list all system files under the directory.

dir /s

CMD list system files

Example 6. CMD list all read-only non-achieve files.

dir /a:r-a

CMD list read only files

Example 7. CMD list all files with the file extension .doc.

Tips:

You can replace the doc with other file extensions such as exe, png, xml, etc.

dir *.doc

CMD list files with doc extension

Example 8. CMD list all files with the file extension .doc and .jpg.

dir *.doc *.jpg

CMD list files with doc and jpg extension

Of course, there are many other dir commands to list file CMD on Windows 10/11 and we can’t explain all in this post. If you want to know more information about Windows CMD list files, you can search for corresponding commands online on Google.

Better Alternative to Command Prompt List Files

Although you can list files in a directory CMD, many professional commands might be unfamiliar to you. How to list all files/folders under a directory more easily? MiniTool Partition Wizard is a better alternative to Windows Command Prompt list files.

Its Space Analyzer feature can show all files/folders under a specific path in the file name, size, last change, extension, percentage of drive, etc. In addition, it tells you what files are taking up your disk space and helps you free up disk space.

MiniTool Partition Wizard FreeClick to Download100%Clean & Safe

list files using MiniTool Partition Wizard

About The Author

Position: Columnist

Ariel has been working as a highly professional computer-relevant technology editor at MiniTool for many years. She has a strong passion for researching all knowledge related to the computer’s disk, partition, and Windows OS. Up till now, she has finished thousands of articles covering a broad range of topics and helped lots of users fix various problems. She focuses on the fields of disk management, OS backup, and PDF editing and provides her readers with insightful and informative content.

  • Use the “DIR” command to list files and folders in the current directory, or “DIR /S” to list files and folders recursively, in subdirectories as well.
  • To search for specific file types use the asterisk followed by the file extension type, in this syntax: DIR *.jpg
  • Use attribute switches to filter the type of files and folders to list.

It can be tricky to keep tabs on all files and folders on a Windows computer, especially if there are too many. There can be many folders and subfolders inside a partition, and many different types of file extensions. It can be difficult to view all the files and folders, or even search for specific ones using File Explorer.

Using the Command Prompt, you can view and list all sorts of files and folders inside a directory, and even its subdirectories using recursive switches. Not only that, but you can also list all items with a specific file type, or exclude them. Moreover, you can also view hidden items as well directly from the Command Prompt.

In this article, we give you a bunch of different examples to list files and folders inside the Command Prompt using the DIR cmdlet.

Command to List Files and Folders in Command Prompt

The DIR command is used to list files and folders inside a directory in Command Prompt. This command can be used with a number of switches and attributes to filter the items to display, their order or displaying, to include and exclude, and so on.

However, the only switches we will be interested in are /a and /s.

Using the DIR command alone will display all the files and folders inside that particular directory. It will not show any hidden items, and it will now show any items inside the subdirectories. However, if you use DIR /a, it will show the hidden items as well.

To perform a recursive search, we must use the /s switch.

The table below summarises the commands to use to list files and folders and these switches:

Command Description
DIR Display items inside the current directory
DIR /a Display all items inside the current directory, including hidden ones.
DIR /s List items inside the current directory as well as all subdirectories
Commands to list files and folders using Command Prompt

With that known, there is a list of attributes that you can use with the DIR /a cmdlet to filter the type of information you want to list. Here is a list of the attributes you can use with /a.

Attribute Alphabet Description Syntax Example
d Shows directories only DIR /ad
h Show hidden items only DIR /ah
s Show system files only DIR /as
l Show reparse points only DIR /al
r Show read-only files DIR /ar
a Show files that can be archived DIR /aa
i Show files whose content is not indexed DIR /ai
– (hyphen) Used before an attribute to exclude it from the list DIR /a-s (hide system files)
: (colon) To combine multiple attributes DIR /a:h-s (Show hidden items but hide system files)
Command Prompt syntaxes to list files and folders using attributes

Example Commands to List Files and Folders in Command Prompt

Let us now continue to see more extensive examples with images to better understand how you can list files and folders using the DIR cmdlet.

  • To list all files and folders in the current directory:

    DIR
    List files and folders in the current directory using Command Prompt

    List files and folders in the current directory using Command Prompt
  • To list all files and folders in the current directory and subdirectories:

    DIR /S
    List recursive files and folders in Command Prompt

    List recursive files and folders in Command Prompt
  • To list only folders in the current directory:

    DIR /AD
    List only folders in the current directory in Command Prompt

    List only folders in the current directory in Command Prompt
  • To list only folders in the current directory and subdirectories:

    DIR /AD /S
    List only folders in the current directory and subdirectories in Command Prompt

    List only folders in the current directory and subdirectories in Command Prompt
  • To list all files in the current directory and exclude all folders:

    DIR /A-D
    List all files and exclude folders in current directory in Command Prompt

    List all files and exclude folders in the current directory in Command Prompt
  • To list all hidden system files in the current directory:

    DIR /ASH
    List all hidden system files in current directory in Command Prompt

    List all hidden system files in current directory in Command Prompt
  • To list all system files and exclude read-only files in the current directory and subdirectories:

    DIR /A:S-A /S
    List all system files and exclude read only files in the current directory and subdirectories using Command Prompt

    List all system files and exclude read-only files in the current directory and subdirectories using Command Prompt
  • To list all specific file type files in the current directory and subdirectories:

    Note: You can change the file type extension to list the files you are looking for.

    DIR *.txt
    List all files with a specific file type using Command Prompt

    List all files with a specific file type using Command Prompt
  • To list multiple file types in the current directory and subdirectories:

    DIR *.txt *.doc *.docx /S
    List multiple file types in the current directory and subdirectories from Command Prompt

    List multiple file types in the current directory and subdirectories from Command Prompt

There can be many different examples and syntaxes to list files and folders inside the Command Prompt. However, we hope that the examples above are sufficient so that you can combine and modify them as per your requirements.

Closing Words

The Windows command line offers much more control over the fetched data than its GUI. Using the Command Prompt, you can list different files and folders inside the current directory as well as its subdirectories. You can also filter out the type of files and folders to include, or exclude from the list.

Когда ко мне обратились с вопросом о том, как быстро вывести список файлов в текстовый файл, я понял, что ответа я не знаю. Хотя задача, как оказалось, достаточно часто встречающаяся. Это может потребоваться для передачи списка файлов специалисту (для решения какой-то проблемы), самостоятельного ведения журнала содержимого папок и других целей.

Решено было устранить пробел и подготовить инструкцию на эту тему, в которой будет показано, как получить список файлов (и вложенных папок) в папке Windows средствами командной строки, а также о том, как автоматизировать этот процесс, если задача возникает часто.

Получение текстового файла с содержимым папки в командной строке

Получение списка файлов в командной строке

Сначала о том, как сделать текстовый документ, содержащий список файлов в нужной папке, вручную.

  1. Запустите командную строку от имени администратора.
  2. Введите cd x:\folder\ где x:\folder\ — полный путь к папке, список файлов из которой нужно получить. Нажмите Enter.
  3. Введите команду dir /a /-p /o:gen >files.txt (где files.txt — текстовый файл, в котором будет сохранен список файлов). Нажмите Enter.
  4. Если использовать команду с параметром /b (dir /a /b /-p /o:gen >files.txt), то в полученном списке будет отсутствовать любая дополнительная информация о размерах файлов или дате создания — только список имен.

Готово. В результате будет создан текстовый файл, содержащий необходимую информацию. В команде выше, данный документ сохраняется в той же папке, список файлов из которой требуется получить. Можно также убрать вывод в текстовый файл, в этом случае список будет отображаться только в командной строке.

Полученный текстовый файл со списком

Кроме этого, для пользователей русскоязычной версии Windows следует учитывать то, что файл сохраняется в кодировке Windows 866, то есть в обычном блокноте вместо русских символов вы увидите иероглифы (но можно использовать альтернативный текстовый редактор для просмотра, например, Sublime Text).

Получаем список файлов с помощью Windows PowerShell

Вы также можете получить список файлов в папке используя команды Windows PowerShell. Если вы хотите сохранить список в файл, то запустите PowerShell от имени администратора, если просто просмотреть в окне — достаточно простого запуска.

Сохранение списка файлов в текстовый файл в PowerSehll

Примеры команд:

  • Get-Childitem -Path C:\Folder — вывод списка всех файлов и папок, находящихся в папке Folder на диске C в окне Powershell.
  • Get-Childitem -Path C:\Folder | Out-File C:\Files.txt — создание текстового файла Files.txt со списком файлов в папке Folder.
  • Добавление параметра -Recurse к первой описанной команде выводит в списке также содержимое всех вложенных папок.
  • Параметры -File и -Directory позволяют получить список только файлов или только папок соответственно.
Список файлов, полученный в PowerShell

Выше перечислены далеко не все параметры Get-Childitem, но в рамках описываемой в этом руководстве задачи, думаю, их будет достаточно.

Утилита Microsoft Fix it для печати содержимого папки

На странице https://support.microsoft.com/ru-ru/kb/321379 присутствует утилита Microsoft Fix It, добавляющая в контекстное меню проводника пункт «Print Directory Listing», выводящий список файлов в папке на печать.

Вывод списка файлов на печать через контекстное меню

Несмотря на то, что программа предназначена только для Windows XP, Vista и Windows 7, она успешно сработала и в Windows 10, достаточно было запустить ее в режиме совместимости.

Дополнительно, на той же странице показан порядок ручного добавления команды вывода списка файлов в проводник, при этом вариант для Windows 7 подойдет и для Windows 8.1 и 10. А если вам не требуется вывод на печать, вы можете немного подправить предлагаемые Microsoft команды, удалив параметр /p в третьей строке и полностью убрав четвертую.

The dir command is used to list files and folders in the Windows command prompt (CMD).

dir

The dir command without a path will display a list of files and folders in the current working directory.

DIR Command - List Files in Windows Command Prompt

You can provide a path to see the listing for a different directory:

dir C:\Windows

By default, the dir command does not show hidden files and folders. To include hidden files, run the dir command as follows:

dir /a

You can use the /B switch to show the file names only without heading information or summary.

dir /b C:\Windows

The /s option lists all files in a specified directory and all subdirectories.

dir /s

List Files Using Patterns

The dir command supports wildcard character (*) that you can use to describe a pattern to match.

For example, the following command lists all files that begin with the letter A:

dir a*

Here is another example that lists all files that have a .doc extension:

dir /b *.doc

Displays files with specified attributes

The /A switch is used to list files and folders with specified attributes. For example, the letter H represents the hidden attribute.

dir /a:h

The following table describes each of the values that you can use for Attributes.

D Folders.
H Hidden files and Folders.
S System files.
L Reparse Points.
R Read-only files.
A Files ready for archiving.
I Not content indexed files.
O Offline files.
Prefix meaning not (See examples).

Examples

List Files and folders in C:\Windows\System32 directory:

dir C:\Windows\System32

Obtain a listing of all files in C:\Windows\System32 that ends with the .txt extension:

dir C:\Windows\System32\*.txt

Search for files with .dll extension in C:\Windows\System32 and all subdirectories:

dir /s C:\Windows\System32\*.dll

Returns the listing for the parent directory of the current working directory:

dir ..

List all files and folders, including hidden files:

dir /a

Show hidden files only:

dir /a:h

List only folders:

dir /a:d

Don’t list folders:

dir /a:-d

Show only hidden folders:

dir /a:dh

List read only files:

dir /a:r

Sort the result by name:

dir /o:n

This will sort the result set by size:

dir /o:s

Sort the result set by size (largest first):

dir /o:-s

Sort the result by date:

dir /o:d

Includes the name of the owner for each file:

dir /q

Show creation time:

dir /t:c

Show last access time:

dir /t:a

Show the last written time:

dir /t:w

Run the dir /? command to see a list of all the available command-line options.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Realtek wireless lan driver windows 10 64 bit
  • Windows memory diagnostic где посмотреть результаты
  • Как скопировать файл из windows в linux через терминал
  • Как включить инверсию цвета на windows 10
  • Как сделать учетку администратора windows 10