The list command in Windows CMD (or `dir`) lets you view files and folders in the current directory. To list visible files only, simply open Command Prompt and run dir. To include hidden files, use dir /a or dir *.txt to filter by extension. No extra tools or permissions are needed—just know the basic syntax and how to customize the output.
What You'll Need
- A Windows system (Windows 7 or newer) with Command Prompt accessible.
- Administrator privileges are only required if you need to modify system directories or run certain specialized commands (e.g.,
dir /sfor a full directory tree). - Access to a file explorer window open in the directory you want to list (optional).
Step-by-Step
-
Open Command Prompt:
- Press
Win + R, typecmd, and hitEnter(Windows 10/11). - Alternatively, search for "cmd" in the Start menu and open it.
- Press
-
Navigate to the folder you want to list (optional):
- Use directory navigation commands like
cd C:\Documentsto change to a specific folder (replace "Documents" with your path). - To return to the root of your drive, use
cdorcd ..to go up one level.
- Use directory navigation commands like
-
Run the basic
dircommand:- Type
dirand pressEnter. This lists visible files and folders in the current directory, formatted with dates, sizes, and a simple directory structure. - Example output:
Volume in drive C is OS Volume Serial Number is 1234-5678 Directory of C:\Users\YourName\Desktop 01/01/2024 10:00 AM 100KB Report.txt 02/01/2024 09:30 AM 512KB Project.zip ------------- 2 File(s) 612KB 0 Dir(s) 4,656KB free
- Type
-
Customize the output with options:
-
List only filenames (no details):
Type
dir /b(e.g.,dir /b *.docxto list only Word documents).Report.txt Project.docx -
Include hidden files (e.g., system files):
Use
dir /afor all hidden files (including system files, which may require UAC elevation).
Example output (restricted to your user profile):dir /aVolume in drive C is OS Volume Serial Number is 1234-5678 Directory of C:\Users\YourName . 01/01/2024 10:00 AM 0 .. 01/01/2024 10:00 AM 0 .DS_Store 01/01/2024 10:05 AM 100B Report.txt 01/01/2024 10:00 AM 100KB -
Filter by file extension (e.g., only .txt files):
Type
dir *.txtordir *.logto list specific file types.dir *.log AppError.log Debug.log -
Show full directory tree (recursive):
Use
dir /sto list all files in the current folder and subfolders.
C:\Data\Reports\Sales.csv C:\Data\Subfolder\Reports\Sales.csv Warning: This command can generate large output; avoid running it on system drives unless necessary.dir /s *.csv -
Hide system files (optional):
Use
dir /o-d /wto sort files by date in descending order and display only names:dir /o-d /w Report.txt Project.zip
-
List only filenames (no details):
Type
-
Redirect output to a file (for advanced users):
- Run
dir > output.txtto save the directory listing to a file. - Useful when scripting or copying large directories.
- Run
Common Mistakes
-
Forgetting to navigate to the correct folder:
Open File Explorer, navigate to the target directory, then run
cmdfrom there. For example, if you want to list files in "C:\Projects", open File Explorer to "C:\Projects" first, then pressWin + R, typecmd, and choose "Run as administrator." -
Running
dir /awithout admin rights: Hidden system files (e.g., `.exe`, `.tmp`) are protected. Usedir /a > hidden.txtin an elevated Command Prompt to save output to a file. -
Using
dir /son system drives: Running this on drives like C:\ can crash your system if it accesses critical files. Always test in a non-system drive first. -
Typo in the command (e.g.,
direinstead ofdir): Command Prompt treats errors like typos as a normal exit, but you won’t see the listing. Always check for typos before pressing Enter.
Tips
-
Shortcut keys for Command Prompt:
Ctrl + C– Stop the current command.Ctrl + V– Paste text (supports clipboard contents).Ctrl + A+Ctrl + X– Cut selected text.Alt + ↑– Duplicate the last command.
-
Use wildcards (*) to filter dynamically:
Run
dir *.tmpto list all temporary files in the current directory. -
Enable verbose mode for long filenames:
Type
dir /wto display filenames without extra padding, which helps with files over 255 characters (common in modern systems). -
Check the current working directory:
Run
echo %cd%to confirm you’re in the right folder before listing files. Example output:C:\Users\YourName\Desktop
Troubleshooting
-
Command Prompt doesn’t open:
- Restart your PC and try again.
- Check if Windows features are enabled: Press
Win + R, typeoptionalfeatures, and enable "Command Prompt" under "Desktop and Networking." - If the issue persists, your system may be missing critical components; reinstall Windows or contact support.
-
Output appears blank or corrupted:
- Ensure you’re in the correct directory (use
dirfirst to verify). - For hidden files, run Command Prompt as Administrator and try again.
- If using
dir /s, try a smaller directory first (e.g.,dir /s *.loginstead ofdir /s).
- Ensure you’re in the correct directory (use
-
Command Prompt says "Access Denied":
- If listing system files (e.g.,
dir /a), you need elevated privileges. Run Command Prompt as Administrator (right-click > "Run as administrator"). - For restricted folders (e.g., C:\Windows), avoid
dir /sunless necessary. Usedir C:\Windowsinstead (it won’t recurse but will list visible files).
- If listing system files (e.g.,
-
Command Prompt freezes or crashes:
- Close and reopen Command Prompt.
- Update Windows (Settings > Windows Update) to ensure compatibility.
- If problems persist, reset Command Prompt via Add/Remove Programs (Settings > Apps > Apps & Features > Command Prompt > Modify > Repair).
Frequently Asked Questions
What is the simplest way to list files in Command Prompt?
The simplest command is dir. It lists visible files and folders in the current directory, formatted with dates and sizes. No extra steps are needed.
Can I list files in a specific folder without navigating there first?
Yes, but you must either:
- Open Command Prompt from that folder (e.g., double-click a folder shortcut in the Start menu), or
- Use the full path in the command, like
dir "C:\Users\YourName\Downloads\*.txt".
Why do I get an "Access Denied" error when using dir /a?
Hidden system files (e.g., `.tmp`, `.exe`) are protected by default. To view them:
- Run Command Prompt as Administrator (right-click > "Run as administrator").
- Alternatively, save the output to a file (e.g.,
dir /a > hidden.txt) to avoid permission issues.
How do I list all files in a folder and its subfolders?
Use dir /s. For example, dir /s *.jpg lists all JPG files in "C:\Pictures" and its subfolders. Be cautious on system drives!
What does dir /w do?
dir /w displays filenames without extra spacing, which helps with long filenames (common in Windows 10/11). Example:
dir /w
My Very Long Filename That Exceeds 255 Characters.docx
ShortName.txt
Is there a way to sort files by date in Command Prompt?
Yes, use dir /o-d to sort by date (newest first) or dir /o-s to sort by size (largest first). Example:
dir /o-d /w
Report20240101.txt
Project.docx