Dir command

August 9, 2009

dir
command can be used to list the files from command prompt. This article explains the syntax for different usecases.

  • A simple dir
    command without any other arguments lists all the files/subfolders that exist in the current folder.

     dir 
  • Lists the subfolders/files names in bare format.
     dir /b 

    This command prints the file names. No other file meta data like file modified time, file size etc are not displayed.

  • List the files in the current folder and also the ones in the subfolders recursively.
     dir /s 

Using wild cards with dir

Dir command accepts wild cards to display information only for the files that match the pattern specified. The below examples illustrate different use cases where we can use these wild cards

  • List files of certain type or based on extension

    For example to list all jpeg files in the current folder, we can run the below command.

     dir *.jpeg 

    To list all excel files

     dir *.xls 

    We can even specify multiple extension in dir command to list files of any of the types. To list all files created with Office applications like Word, Excel, Powerpoint etc we can run below command.

     dir *.docx *.xlsx *.pptx 
  • List files beginning/ending with specific pattern

    List all files in the current folder whose names begin with ‘Picture-‘

     dir /S Picture-* 

List file names based on type

dir command can list the file names and also the subfolders names. We can be selective and say that we want only names of the files to be listed or only the names of the subdirectories to be listed.

  • List only directories
     dir /A:D 
  • List only files
     dir /A:-D 

Display files based on file attributes

We can filter out which files should be listed in the dir
command output based on read-only, system, hidden archive file attributes.

  • For example, to list read-only files in the current directory, the command is:
     dir /A:R 
  • Similarly to display hidden files
     dir /A:H 
  • For the opposite case of looking for files where an attribute is not set, we can append '-'
    to the attribute code. For example, to print the file names without archive attribute set, we can use the below command.

     dir /A:-A 
  • Exclude Read-only files from the listing.
     dir /A:-R 
  • Exclude hidden files from listing.
     dir /A:-H 
  • Exclude system files from listing
     dir /A:-S 

Print metadata of files using dir command

  • Find out who owns a file
     dir /Q 
     c:\>dir /Q 1.txt
    05/03/2015 01:12 AM 151,906 BUILTIN\Administrators 1.txt 
  • Get created time of a file
     dir /TC 
  • Find last accessed time of a file
     dir /TA 
  • Find last modified time of a file
     dir /TW 

Windows command prompt MS-DOS provides the dir
command in order to list files. The dir command provides different features while listing the files. Actually, the dir command does not only list files it also lists directories too. In this tutorial, we will learn how to list files in command prompt in different ways like specific extension, recursive list, etc.

List Files with dir Command

The dir command is a very old command provided by MS-DOS. The dir command is used to list files and folders. Without providing any option to the dir command prints all files and folders in the current directory.

 dir 
Dir command
List Files and Folders with dir Command

Only files can be listed by using the /b
and /a-d
options with dir command. The /b command use bare format where only file names are listed. Also /a-d option is used to not list directories where only files are listed.

 dir /b /a-d 
Dir command
List Files with dir Command

Alternatively the bare formattin can be disabled without providing the /b option like below.

 dir /a-d 
Dir command
List Files with dir Command

List Files Located in Different Path

 dir C:\Users\ismail\Desktop 
Dir command
List Files in Different Path

Alternatively only files can be listed like below.

 dir /b /a-d C:\Users\ismail\Desktop 
Dir command
List Files in Different Path

List File Types

 dir *.zip 

Alternatively we can list zip files located other directories by providing the directory path.

 dir C:\Users\ismail\Desktop\*.zip 

List All Files Recursively

By default, the dir lists files located in the current working directory or provided path. It does not list the child directories and child files located in these directories. The /S
option can be used to list all files located in the child directories.

 dir /S 

We can specify the path to list another than the current working directory recursively.

 dir /S C:\Users\ismail\Desktop\ 
 dir /S C:\Users\ismail\Desktop\*.sys 
Dir command

  • Home

  • Partition Magic

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

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.

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.

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.

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
.

run dir in the cmd

Example 2. C MD List folders of the current directory only
.

run dir ad

Example 3. C MD list files only under the directory
.

cmd list files only

CMD list files of a specific directory

Example 5. C MD list all system files under the directory
.

CMD list system files

Example 6. C MD list all read-only non-achieve files
.

CMD list read only files

Example 7. C MD list all files with the file extension .doc
.

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

CMD list files with doc extension

Example 8. C MD 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 Free Click to Download

Clean & Safe

list files using MiniTool Partition Wizard

About The Author

Somehow like dir /b
command but I need also hidden and system files there. Built in dir command doesn’t allow to list such ‘hidden’ files with the rest and I must use /s
to have full path in there, which is of course non recursive.

I also played with windows version of ls
command and there also no luck. To display full path you must add asterisk ( mydir\*
) at the end of directory you are listing, but this makes it recursive.

asked Apr 26, 2012 at 17:10

rsk82's user avatar

 for /f "delims=" %a in ('cd') do @for /f %b in ('dir /b /a') do @echo %a\%b 

You have to cd
into the directory first or it won’t work.

answered Apr 26, 2012 at 17:42

Dennis's user avatar

12 gold badges
130 silver badges
149 bronze badges

 dir /s /b /a 

It will give ALL files, you can run it through FIND
if you want or add a folder name.

Renan's user avatar

4 gold badges
39 silver badges
48 bronze badges

answered Aug 1, 2012 at 18:19

bjkamp's user avatar

1 silver badge
2 bronze badges

If you tried ls, why not just install cygwin? You can use find in cygwin:

 find -name "*" 

If you do install cygwin and want to use find in cygwin, make sure the find in cygwin is called by either using full path or insert cygwin bin path before system32 because Windows also has a find.exe.

answered Apr 26, 2012 at 17:19

Codism's user avatar

12 silver badges
18 bronze badges

you could download sed with gnuwin32. This prepends the current directory.

Doing %cd% doesn’t work. so %cd:\=\\%
converts every \
to \\
, which results in \
.

 C:\WINDOWS>dir /b | sed "s/^/%cd:\=\\%\\/"
C:\WINDOWS\0.log
C:\WINDOWS\003109_.tmp
C:\WINDOWS\addins 

answered Apr 26, 2012 at 17:28

barlop's user avatar

43 gold badges
144 silver badges
225 bronze badges

This is an old question, but I thought I’d add something anyhow.

DIR doesn’t traverse correctly all the directory trees you want, in particular not the ones on C: It simply gives up in places because of different protections.

ATTRIB works much better, because it finds more. ( Why this difference? Why would MS make one utility work one way and another work different in this respect? Damned if I know.) In my experience the most effective way to handle this, although it’s a kludge, is to get two listings:

 attrib /s /d C:\ >%TEMP%\C-with-directories.txt
attrib /s C:\ >%TEMP%\C-without-directories.txt 

answered Jan 16, 2014 at 13:50

djc's user avatar

I wanted to work with a directory listing, so I Googled “Print a Directory”. I found instructions to do so, but they included changes to the Registry. Not wanting to diddle with this, and wanting to use a listing, not print it, I found a way to meet my goals without changing the Registry. I created two batch file programs to be saved in a Utility Directory. Then, when I wanted to print or work with a directory, I just copy the appropriate batch file into the subject directory, then execute it! Here they are:

 rem PrintThisDirectory.bat
rem Prints the directory where it resides
@echo off
dir %1/-p/o:gn> "%temp%\listing"
start /w notepad "%temp%\listing"
Rem ShowThisDirectory.bat
Rem Displays in Notepad the Directory where it resides
@echo off
dir %1/o:gn> "%temp%\listing"
start /w notepad "%temp%\listing" 

answered Nov 2, 2014 at 18:02

Roger Bohl's user avatar

Alternative #1: FOR /R is more intuitive than #2 for me.

Alternative #2: FOR /F fixes the problem with “spaces in names” in BrianAdkins’ suggestion.

Alternative #3: FORFILES would be my pick except that the path is in double quotes.

Brian or other gurus may have a more elegant solution or may be able to suggest a dozen other solutions but these three work. I tried using FOR TOKENS but then had to strip headers and footers so I reverted back to #1. I also considered creating a small .bat file and calling it but that adds another file (although it does provide greater flexibility, as would a function).

I tested all alternatives with directory and filenames with embedded spaces, a 200+ character filename, a filename with no extension, and on root of a small drive (just for time; a little slow — just as Brian suggested — but then so is searching in Windows Explorer; that is why I installed Everything search app).

Alternative #1: FOR /R

Best(?)
While trying to figure out why Brian’s solution didn’t work for me I looked at HELP FOR and decided to try the /R approach. (Creating a file would be the same as in Alternative #2.)

 @echo off & for /R "c:\deletelater\folder with spaces" %A in (*.*) do echo %~fA %~zA 

Example – Works
(different directory than above to demonstrate recursion)

 @echo off & for /R "c:\deletelater" %A in (*.*) do echo %~fA %~zA
c:\DeleteLater\Name with Spaces.txt 19800676
c:\DeleteLater\NoSpacesLongName.txt 21745440
c:\DeleteLater\Folder with Spaces\2nd Name with Spaces.txt 5805492
c:\DeleteLater\Folder with Spaces\2ndNoSpacesLongName.txt 3870322
c:\DeleteLater\FolderNoSpaces\3rd Name with Spaces.txt 27874695
c:\DeleteLater\FolderNoSpaces\3rdNoSpacesLongName.txt 28726032 

Alternative #2: FOR /F

A corrected answer
is:

 @echo off & for /f "delims=*" %A in ('dir /s /b') do echo %~fA %~zA  

A more complete
answer with directories suppressed and output (appended) to a file is:

 @echo Results on %DATE% for %CD% >> YourDirFile.txt & echo off & for /f "delims=*" %A in ('dir /s /b /a:-d') do echo %~fA %~zA >> YourDirFile.txt 

Note: “delims=*” specifies a character not allowed in filenames.

Note: 2nd command also suppresses directories via /a:-d.

Note: Made the FOR variable name uppercase to clarify the distinction between variable and variable parameters if someone chooses different variable names.

Note: Appended to file just for grins as the OP asked for output to a file.

Issue – Spaces in Names

Brian’s proposed solution does not handle file and folder names containing spaces (at least not on my Vista configuration).

Example – Wrong

(Without delims; Includes suppressing directory per OP but with size both before and after filename for emphasis)

Truncated Name and Size (4 of 6 files incorrect):

 @echo off & for /f %A in ('dir /s /b /a:-d') do echo %~zA %~fA %~zA C:\DeleteLater\Name
21745440 C:\DeleteLater\NoSpacesLongName.txt 21745440 C:\DeleteLater\Folder C:\DeleteLater\Folder C:\DeleteLater\FolderNoSpaces\3rd
28726032 C:\DeleteLater\FolderNoSpaces\3rdNoSpacesLongName.txt 28726032 

Example – Correct

(Note output to screen, not appended to file)

 @echo off & for /f "delims=*" %A in ('dir /s /b /a:-d') do echo %~fA %~zA
C:\DeleteLater\Name with Spaces.txt 19800676
C:\DeleteLater\NoSpacesLongName.txt 21745440
C:\DeleteLater\Folder with Spaces\2nd Name with Spaces.txt 5805492
C:\DeleteLater\Folder with Spaces\2ndNoSpacesLongName.txt 3870322
C:\DeleteLater\FolderNoSpaces\3rd Name with Spaces.txt 27874695
C:\DeleteLater\FolderNoSpaces\3rdNoSpacesLongName.txt 28726032 

Alternative #3: FORFILES (Quote Issue)

This solution is straight from the last two examples in the FORFILES documentation ( forfiles /?
).

 FORFILES /S /M *.doc /C "cmd /c echo @fsize"
FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file" 

Combining these examples and writing to a file yields the answer (almost):

 forfiles /s /c "cmd /c if @isdir==FALSE echo @path @fsize" >>ForfilesOut.txt 

Caution

: Using the mask /m *.*
will not return files without extension (like last file in example)!

Example – Works
(but with fullpath in quotes)

 forfiles /s /c "cmd /c if @isdir==FALSE echo @path @fsize"
"c:\DeleteLater\Name with Spaces.txt" 19800676
"c:\DeleteLater\NoSpacesLongName.txt" 21745440
"c:\DeleteLater\Folder with Spaces\2nd Name with Spaces.txt" 5805492
"c:\DeleteLater\Folder with Spaces\2ndNoSpacesLongName.txt" 3870322
"c:\DeleteLater\FolderNoSpaces\3rd Name with Spaces.txt" 27874695
"c:\DeleteLater\FolderNoSpaces\3rdNoSpacesLongName.txt" 28726032
"c:\DeleteLater\MoreFiles\A really really long file name that goes on and on 123456789 asdfghjkl zxcvnm qwertyuiop and still A really really long file name that goes on and on 123456789 qwertyuiop and still further roughly 225 characters by now.txt" 447
"c:\DeleteLater\MoreFiles\New Text Document no extension" 0 

This example includes an extra directory with a super long filename and a filename with no extension.

Issue: Path in Quotes

So, is there an easy way to remove the unwanted(?) quotes per the OP example and save Alternative #3: FORFILES. (Rhetorical question: Are the quotes a feature or a flaw?)

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 
 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.

 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 

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.


Files are used to store computer programs, textual documents, audio video streams, and libraries. In contrast, a folder is a unit to store files and is also called a directory. The file and folders are essential units of any computer system. In Windows, the folders and files can be listed using “ dir
” in the Command Prompt.

This tutorial will elaborate on the approaches to listing Windows files using the command line.

What is the “dir” Command?

dir
” is derived from the word “ directories
” and is mainly used to list the file and directories of the system. Many options are available that are supported by the “ dir
” command in Windows to view different types of such files.

Check out the below-given table to have an idea about it:

After having the basic information related to the “ dir
” command, let’s move ahead towards its implementation side.

Step 1: Open Command Prompt

Press the “ Window+R
” key, type cmd, and press the “ OK
” button to open Command Prompt:

Dir command

Step 2: List all Directories and Files

To view a list of all files and directories, simply use the “ dir
” command without any option:

Dir command

Now, let’s take a look at some examples of using the “ dir
” command with the different options.

Example 1: View Only List of Folders

Utilize the “ ad
” options to view only a list of folders:

Dir command


Dir command

Example 2: View Only List of Files

To view only a list of all files on the Windows command line, use the “
” sign as “ a-d
”. The hyphen reverses the functionality of the added options:

Dir command

Example 3: View List of Files and Folders in a Specific Directory

To view a list of files and folders in a specific directory, first, you need to move to that directory using the “ cd
” command. After that, utilize the “ dir
” command:

Dir command

Example 4: View List of Hidden System Files

The “ s
” option is used to display system files, and the “ h
” option is used to display a list of hidden files.

Therefore, to list all of the hidden system files, utilize the “ ash
” option in the “ dir
” command:

Dir command

Example 5: List All Folders and Files

List all system folders and files using the “ s
” option:

Dir command

Example 6: List File and Folder by Specifying Wildcard

Use “ v

*” as a wildcard to view the list of files starting with the “ dir /o:-s v dir /a
” alphabet:

 

We have illustrated the examples to list the files in Windows using the command line. dir /o:s

Conclusion

 To list files in Windows using Command Line, first, open up the Command Prompt, then utilize the “ 

dir

” command. This will list the folders and files in the current directory. The “

dir
” command supports many options, which are practically demonstrated in different examples. This article demonstrated how to list files on Windows using the “ 

dir dir ..
” command.

 About the author 

 dir /a:h 

 I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP. 

dir /a:d Looking to manage all files across many directories? Here is how to list and sort them in Command Prompt.

 dir /a:-d 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. dir /a:dh

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 dir /a:r
. 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 dir /o:n
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:

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
.

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 /a:dh 

    dir /o:-s dir /a:d

    List all hidden system files in current directory in Command Prompt

  •  dir /a:-d 

    To list all system files and exclude read-only files in the current directory and subdirectories:
     

     dir /a:r 

     List all system files and exclude read-only files in the current directory and subdirectories using Command Prompt 

    dir /o:n

    To list all specific file type files in the current directory and subdirectories: dir /o:s

     

    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.

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

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


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

Для чтения содержимого каталогов в старой доброй командной строке предусмотрена команда , её то как раз мы и будем использовать. Итак, запускаем консоль CMD
, командой (если нужно перейти в другой диск, добавляем после cd ключ /d)

переходим в нужное расположение и выполняем эти две команды:

 chcp 1251
dir /b /s > D:\filelist.tхt 

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

Первая команда устанавливает кириллическую кодировку, вторая сохраняет список всех файлов, папок и вложенных в них объектов в текстовый лог на диске D

.

Текстовый лог

Если нужно получить список только файлов (без вложенных каталогов)

, достаточно использовать только ключ /b
.

Примечание:
в Windows 8.1 и 7 для быстрого перехода в папку в командной строке, зажмите Shift
, кликните ПКМ
по папке и выберите в контекстном меню опцию «Открыть окно команд»
.


Список файлов и папок в PowerShell

В Windows 10 командная строка заменена консолью , для получения списка файлов можете использовать её. Для примера выведем в файл содержимое папки Тест с её подкаталогами:

 Get-Childitem -Path D:\Тест -Recurse | Out-File D:\filelist.tхt 

PowerShell

А можно и проще. Зажав Shift
, кликаем по папке ПКМ
, выбираем в меню «Открыть PowerShell здесь»
.

Открыть PowerShell здесь

Get-Childitem

Необходимость использования параметра -Path

с указанием пути в данном случае отпадает.


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

Этот способ позволяет получить список либо файлов, либо папок в конкретном расположении. Заходим в целевую папку, выделяем в ней все файлы или папки, зажимаем Shift
, кликаем правой кнопкой мыши и выбираем в меню опцию «Копировать как путь»
.

Копировать как путь

Пути и имена выделенных объектов будут переданы в буфер обмена, откуда вы уже сможете перенести их в текстовый файл.


Getting a list of files with DirLister

To get a well-structured list of file system objects, you can use the free portable utility DirLister
by downloading it from the official site:

After running the utility, specify in the section “Directory To Scan”
path to the scanned directory or disk, in the section “Output File”
select a location to save the list.

DirLister

Here you can also set scanning parameters - select the format, specify whether nested directories and hidden objects should be included in the list, set the search by mask. After pressing the button "Make List"
the list will be saved in the selected location.


Use the browser to get the list of files

At worst, you can use any browser to create a list of files and folders on the disk. We drag a folder or drive to a new browser tab and get a list of files and directories in it.

Список файлов в браузере

Recursively go through all nested directories, however, it will not work, and to copy the paths and file names and transfer them to a separate file, you will have to use Ctrl
+ C
and Ctrl
+ V
.

:/>  Управление драйверами Windows с помощью командной строки с использованием DevCon

Оставьте комментарий