Get IT Solutions

How to do IT
Menu
  • Home
  • SCCM 2012
    • Deploy Packages
    • Troubleshooting errors SCCM 2012
  • Windows
    • Applications Silent Install
    • Windows Tools
    • Windows Error
    • Script
    • Exchange Server
    • Troubleshooting Office
    • Applications Errors
  • Database
    • SQL Server
    • MySQL
    • Oracle
  • Cybersecurity
  • Other
  • Reviews

How to list files in cmd – Command Prompt – Windows 10

Whenever you want to search and make a list of all files on a specific folder, you used the windows explorer interface to do that. But today in this article we will show other easy ways to that. We will list files using the cmd tool. Command-line provides a simple way to list all the files of a certain type– for example, all your PDF files using the “dir” command. This command will be old news to many but it remains one of the most useful for average PC users. At the end of the post, you will have all switches in order t play with them based on your needs,

Table of Contents

  • How to List all the files in a folder using CMD
  • How to List all the files in a folder and subfolder using CMD
  • How to list specific file using wildcards
  • How to Display Based on File Attributes
  • How to create a text file listing of the files
  • How to create a text file listing only certain types of files
  • How to display only files without folder names
  • How to Display Results in Columns
  • How to Display Results in Lowercase
  • Display Results Sorted by Time
  • All Switches Key
  • Conclusion:

How to List all the files in a folder using CMD

  1. Searching on windows the “cmd” name an open as administrator
  2. Navigate to your path where you need to list the file by type cd and the path:
cd c:\Test\
  1. Click Enter
  2. Execute the following command
dir

Enter “dir” to list the files and folders contained in the folder.

 

How to List all the files in a folder and subfolder using CMD

If you want to list the files in all the subfolders as well as the main folder, enter:

dir /s

The lists can be quite long and we will create a file containing the list in order to be very easy. You can rename multiple files at once using CMD.

 

How to list specific file using wildcards

The dir command can also be used to search for specific files and directories by using wildcards. For example, to list files or directories that begin with the letter “B” you could type:

dir b*

To list only the items starting with the B letter.

 

How to Display Based on File Attributes

You can add “/A” followed by a letter code after the DIR command to display files with a specific attribute. These letter codes include:

  • D: Displays all directories in the current path
  • R: Displays read-only files
  • H: Displays hidden files
  • A: Files that are ready for archiving
  • S: System files
  • I: Not content indexed files
  • L: Reparse points

 

How to create a text file listing of the files

  1. Open the command line in the folder of interest. Example:
cd c:\Test\
  1. Execute the following command:
    dir > listoffiles.txt
  2. The command will create a list with the files and folders contained in the folder.
  3. If you want to list the files in all the subfolders as well as the main folder, enter the following command
dir /s >listmyfiles.txt

The file “listoffiles.txt” will be created automatically in the working folder.

Give the full pathname to create the file elsewhere. For example:

dir >D:\listmyfiles.txt

Could be used to place the list on an external drive D:

 

How to create a text file listing only certain types of files

You may want a list of certain types of files such as pdf files. The dir command allows the use of the wildcard symbol *, which adds very useful functionality. Here are some examples.

How to create a list of all the PDF files in a folder and its subfolders:

The command is:

dir /s *.pdf >listpdf.txt

The command will create a list of PDF files only.

READ ALSO -   Cloning HDD using command prompt

A simpler format:

The commands as written will make lists that include information about files such as size and date of creation. A simpler list containing only file names (with full path) can be obtained with the switch “/b”. An example would be:

dir /s/b *.pdf >listpdf.txt

You can also change extension of multiply files using the command line.

 

How to display only files without folder names

Adding /a-d to the command removes the names of the directories, so all we have are the file names.

dir /a-d /b >..\listmyfiles.txt

 

How to Display Results in Columns

You can use the /D switch to display results in two columns instead of one. When you display results this way, the Command Prompt does not show extra file information (file size and so on)—just the names of the files and directories.

dir /D

 

How to Display Results in Lowercase

The /L switch displays all names of files and folders as lowercase.

dir /L

 

Display Results Sorted by Time

Using the /T switch along with a letter code lets you sort results by the different time stamps associated with files and folders. These letter codes include:

  • A:The time the item was last accessed.
  • C:The time the item was created.
  • W:The time the item was last written to. This is the default option used.

So, for example, to sort results by the time items were created, you could use the following command:

dir /TC

 

All Switches Key

Below are all switches where you can use to create a complex list:

 

Syntax      DIR [pathname(s)] [display_format] [file_attributes] [sorted] [time] [options]

Key

  • [pathname] The drive, folder, and/or files to display, this can include wildcards:
    • *  – Match any characters
    • ?  – Match any ONE character
  • [display_format]
    • /P   Pause after each screen of data.
    • /W   Wide List format, sorted horizontally.
    • /D   Wide List format, sorted by vertical column.
  • [file_attributes] /A[:]attribute
    • /A:D  Folder         /A:-D  NOT Folder
    • /A:R  Read-only      /A:-R  NOT Read-only
    • /A:H  Hidden         /A:-H  NOT Hidden
    • /A:A  Archive        /A:-A  NOT Archive
    • /A:S  System file    /A:-S  NOT System file
    • /A:I  Not content indexed Files  /A:-I  NOT content indexed
    • /A:L  Reparse Point  /A:-L  NOT Reparse Point (symbolic link)
    • /A:X  No scrub file  /A:-X  Scrub file    (Windows 8+)
    • /A:V  Integrity      /A:-V  NOT Integrity (Windows 8+)
    • /A    Show all files

Several attributes can be combined e.g. /A:HD-R

  • [sorted]   Sorted by /O[:]sortorder
    • /O:N   Name                  /O:-N   Name
    • /O:S   file Size             /O:-S   file Size
    • /O:E   file Extension        /O:-E   file Extension
    • /O:D   Date & time           /O:-D   Date & time
    • /O:G   Group folders first   /O:-G   Group folders last

 

several attributes can be combined e.g. /O:GEN

  • [time] /T:  the time field to display & use for sorting
    • /T:C   Creation
    • /T:A   Last Access
    • /T:W   Last Written (default)
  • [options]
    • /S     include all subfolders.
    • /R     Display alternate data streams.
    • /B     Bare format (no heading, file sizes, or summary).
    • /L     use Lowercase.
    • /Q     Display the owner of the file.
    • /N     long list format where filenames are on the far right.
    • /X     As for
    • /N but with the short filenames included.
    • /C     Include thousand separator in file sizes.
    • /-C    Don’t include a thousand separators in file sizes.
    • /4     Display four-digit years. In most recent builds of Windows, this switch has no effect.

The number of digits shown is determined by the ShortDate format set in the Control Panel.

 

Conclusion:

This is all about the methods of how to list files in cmd. Not only but also playing with to get a certain result like export them on a text file or listing only certain types of files.

Share
Tweet
Google+
Pinterest
Linkedin
Stumble
Email
Prev Article
Next Article

Related Articles

Three different ways on how to export and import scheduled tasks
Dear followers of Get-ITsolutions.com, as you may now we have …

Three different ways on how to export and import scheduled tasks

Change extension of multiple files at once
The following article will teach the methods to change the …

Change extension of multiple files at once – CMD batch file

Best Computers & Laptops

Best Computer for Cyber Security – Laptop and Desktop
Best Computer for Cyber Security
Hey, are you seeking the best computer for cyber security? Well, we must say you have come to the right place to find your answer and guidance. There are a plethora of products out there for you to pick from ...
Read More
Best Computer for Microsoft Office & Excel – Laptop and Desktop
Best Computer for Microsoft Office & Excel
Are you finding the Best Computer for Microsoft Office and Excel? In modern days, the best laptop or desktop set is the one which is both portable, has good looks and offers the smoothest performance. Microsoft Office is a package ...
Read More
Best Computer for Hacking – Laptop and Desktop Selection
Best computer for Hacking
When it comes to hacking, either laptop or desktop, choosing the best computer for hacking would be an exhilarating job. There are many specifications to be considered for hacking ...
Read More

SQL Server Tips

FIX sqlstate 42000 – mysql error 1064 – you have an error in your sql syntax
Sqlstate 42000 Is a general code that come together with other number. Most often comes with the code 1064 and ...
Read More
The execute permission was denied on the object – SQL Server Error
The execute permission was denied on the object
The following article will handle “the execute permission was denied on the object” error appears on SQL Server. This error ...
Read More
How to Read Data from LDF file in SQL Server – A Complete Guide
Read LDF File
Hello Everyone, Today we are going to address the most popular query of SQL users, how to read data from ...
Read More

Search

We are on:

Get FREE SPACE for your PC

3 Method to Delete Temp Files in Windows 7/10 including vbs script

In this post we will explain how to delete temp files windows 7 using three different methods including vbs script ...
Read More

Fastest way to delete hiberfil sys from windows 10/8/7 and XP – CMD

In this article we will explain how to remove or delete hiberfil sys from Windows 10/8/7 and XP . If you does ...
Read More

Learn How to Silent Install Applications

Silent Install Adobe Flash Player
In this tutorial will explain how to silent install adobe flash player 25, Msi and Exe version. How to disable auto update and uninstall older ...
Read More
Java Silent Install and Uninstall Older Version – Deploy Package MSI
This tutorial will explain how to silent install Java MSI/EXE version and disable auto-update. The command line will also uninstall the ...
Read More
Silent Install Adobe Shockwave Player 12 and disable update
In this tutorial will explain how to silent install Adobe Shockwave Player 12 msi and disable auto update. The command will uninstall older ...
Read More
Silent Install Google Chrome MSI, Silent Uninstall and Disable Auto Update
This tutorial will explain how to silent install Google Chrome MSI and disable auto update. The command will uninstall older version of ...
Read More
Silent Install Adobe Reader 11 and DC – msi and exe – disable update
In this tutorial will explain how to silent install Adobe Reader version 11 and DC. We will user both version "msi" ...
Read More
Silent Install Mozilla Firefox msi and exe file – Including Silent Uninstallation
This tutorial will explain how to silent install Mozilla Firefox. We will use MSI and EXE files to perform a silent ...
Read More
Skype Silent Install Msi and disable updates
In this tutorial will explain how to silent install skype  and disable auto update. The command will uninstall older version of Skype and ...
Read More
Filezilla Silent Install msi and exe version
Filezilla silent install tutorial will explain how to perform a silent installation of application. We will explain methods, silent install ...
Read More
Silent install VLC Media Player
In this tutorial will explain how to silent install VLC Media Player. We will explain both methods for exe and ...
Read More
Notepad++ silent install exe and msi version – Command Line
Notepad++ silent install is the new article from a series of silent installations. Notepad++ as free software has two main ...
Read More

Batch File Solutions

How to list files in cmd – Command Prompt – Windows 10
Whenever you want to search and make a list of all files on a specific folder, you used the windows ...
Read More
Batch rename multiple files in folder – CMD script – Bulk Method – Win 10
The following article will teach how to rename multiple files in a folder with the bulk method using Command Line ...
Read More
Batch script rename file using Command Line (CMD) & PowerShell – Windows 10
The following article will use the “rename” or “ren” command to rename the file using a command prompt. Also, we ...
Read More
Change extension of multiple files at once – CMD batch file
The following article will teach the methods to change the extension of multiple files at once using command prompt and ...
Read More
How to delete registry key with command line | PowerShell | Batch
The following article is the third of series about registry and working on it through command line (CMD) and PowerShell ...
Read More
How to add registry key & values with CMD | PowerShell | Batch
The registry is the place where most of the applications store the settings but not only. Used also from the ...
Read More
Unmap Network Drive CMD – (Batch file) – net use delete command
After we posted the methods to map network drive using cmd commands we come this time with the method to ...
Read More
Map Network Drive cmd (batch file) – net use user password
This article will focus on another way to map a network drive on your computer instead of from the explorer ...
Read More
How to Find Large Files on Windows 7 & 10 – CMD Forfiles Command
If the capacity of your hard drive is running low, it is time to clean off some files and to ...
Read More
CMD Script to check disk space on windows and multiple remote servers
The following article will provide you script to check disk space. The Script monitor space on windows and multiple remote ...
Read More

Get IT Solutions

How to do IT

About Us

Get IT Solutions is a personal blog, which is managed to guide people for various topic.

Second Menu

  • Donate
  • About Us
  • Contact Us
  • Privacy Policy

What Will You Find

Automation is our area of writing where are included scripts, batch and various tips to automate your daily job.
Copyright © 2025 Get IT Solutions