How to list files in a directory or folder on the computer

Updated: 09/15/2017 by Computer Hope

MS-DOS and Windows command line

dir commandTo list files while at the MS-DOS prompt or in the Windows command line, use the dir command, as shown below.

The example below is also an example of how the files are listed when using the dir command. See the dir command help page for all of the available switches that can be added to this command to perform different functions.

Example of dir command output

Note: By default, the dir command lists the files and directories for the current directory. In the example below, we're in the Windows directory, so only files and directories in the Windows directory are shown.

C:\Windows> dir

Volume in drive C has no label. Volume Serial Number is 6464-D47C Directory of c:\windows 04/13/2016 06:24 AM <DIR> . 04/13/2016 06:24 AM <DIR> .. 10/30/2015 01:24 AM <DIR> addins 04/17/2016 07:10 AM 19,326 PFRO.log 10/30/2015 01:18 AM 32,200 Professional.xml 12/23/2015 04:30 AM <DIR> Provisioning 10/30/2015 01:17 AM 320,512 regedit.exe 12/17/2015 08:09 PM <DIR> Registration 04/18/2016 11:28 AM <DIR> rescache 12/17/2015 08:04 PM <DIR> Resources 06/07/2010 03:27 PM 1,251,944 RtlExUpd.dll ... 07/13/2009 11:09 PM 403 win.ini 04/17/2016 07:10 AM <DIR> WinSxS 10/30/2015 01:18 AM 11,264 write.exe 32 File(s) 839,433,436 bytes 81 Dir(s) 341,846,921,216 bytes free

If there are too many files listed in one directory, you can also show the files one page at a time by using the dir command with the /p switch.

dir /p

You can list files that only meet certain criteria by using wildcards in the dir command. Below are a few additional examples of the dir command with wildcards.

dir *.txt

In the above example, only files that have a file extension of .txt are displayed.

dir a*.*

In the above example, only files that begin with the letter "a" are displayed.

Tip: See our wildcard definition for further information about this term and additional examples.

List the files in a Windows PowerShell directory

Like the Windows command line, Windows PowerShell can use the dir command to list files in the current directory. PowerShell can also use the ls and gci commands to list files in a different format.

List the files in a Linux and Unix directory

ls commandTo list files in a Linux or Unix command line, use the ls command, as shown below. If you need additional examples and syntax on the ls command, see the ls command help page.

[~/public_html/rss]# ls
./ ../ history.rss issues.rss jargon.rss newjarg.rss newpages.rss newqa.rss

Tip: We recommend using ls -laxo to view files, since it gives you full file information and permission information in a more easy to ready format.

You can list files that only meet certain criteria by using wildcards in the ls command. Below are a few additional examples of the dir command with wildcards.

ls *.txt

In the above example, only files that have a file extension of .txt are displayed.

ls r*

In the above example, only files that begin with the letter "r" are displayed.

ls [aeiou]*

In the above example, only files that begin with a vowel (a, e, i, o, u) are displayed.

Tip: See our wildcard definition for further information about this term and additional examples.

Show the files in a Windows folder

Microsoft Windows users who want to list files on the computer can open My Computer or Windows Explorer and open the C: drive. Once in the C: drive, all files and folders in the root directory of your primary hard drive are listed and should resemble the example shown below.

Tip: In Windows, all your programs are typically stored in the Program Files folder and all your documents are usually saved in the My Documents folder.

Windows File Explorer

Tip: See the Windows command line steps if you are in the Windows command line.

Show the files on Apple macOS

Apple users can list files through the Finder. If you are in the Terminal, see the Linux steps that also work in the Terminal.

Additional information