How to list files in a directory or folder on the computer
To list or view the files of a directory or folder on your computer, follow the steps below for your operating system.
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.
In Windows, most of your programs are stored in the Program Files folder, and your documents are frequently saved in the My Documents folder.
See the Windows command line steps if you are in the Windows command line.
MS-DOS and Windows command line
To 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 the available switches that can be added to this command to perform different functions.
Example of dir command output
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 display them one page at a time using the dir command with the /p switch.
dir /p
You can list files that only meet certain criteria using wildcards in the dir command. Below are a few additional examples of the dir command with wildcards.
dir *.txt
In the example above, only files with a file extension of .txt are displayed.
dir a*.*
In the example above, only files that begin with the letter "a" are displayed.
See our wildcard definition for further information about this term and more examples.
dir c:\windows
In the example above, this command lists the files in the C:\Windows directory regardless of the current directory or drive.
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
To 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
We recommend using ls -laxo to view files, as it gives you full file information and permission information in an easier to read format.
You can list files that only meet certain criteria using wildcards in the ls command. Below are a few additional examples of the dir command with wildcards.
ls *.txt
In the example above, only files with a file extension of .txt are displayed.
ls r*
In the example above, only files beginning with the letter "r" are displayed.
ls [aeiou]*
In the example above, only files that begin with a vowel (a, e, i, o, u) are displayed.
See our wildcard definition for further information about this term and additional examples.
ls ~ /public_html
In the example above, the ls command lists all files in the public_html in the home directory (represented by the tilde). If this directory did not exist, you would get an error.
The tilde is a shortcut. Without the shortcut you would need to type the full directory name. For example, if your username was "hope" your home directory would be /home/hope. You can see the full working directory you're currently in with the pwd command.
Show the files on Apple macOS
MacBook and iMac users can list files through the Finder application. To open Finder, click it's icon in the Dock near the bottom-left corner of the desktop.
Once you've opened Finder, use the sidebar to enter and view different folders and directories.
If you are familiar with the Terminal in macOS, you use these Linux steps to view the files in a directory.