How to count how many files are in a folder or directory
Counting files in Windows 8, 10, and 11
- Open Windows Explorer.
- Browse to the folder containing the files you want to count. As shown in the picture below, in the right details pane, Windows displays how many items (files and folders) are in the current directory. If this pane is not shown, click View and then Details pane.
If hidden files are not shown, these files are not counted.
If any file or folder is highlighted, only the selected items are counted.
Use the search box in the top-right corner of the window to search for a specific type of file. For example, entering *.jpg would display only JPEG (Joint Photographic Experts Group) image files in the current directory and show you the count of files in the bottom corner of the window.
If you need to use wildcards or count a more specific type of file, use the steps below for counting files in the Windows command line.
Counting files in Microsoft Windows Vista and 7
- Open Windows Explorer.
- Navigate to the folder containing the files you want to count. In the bottom left portion of the window, it displays how many items (files and folders) are in the current directory.
If hidden files are not shown, these files are not counted.
If any file or folder is highlighted, only the selected items are counted.
Use the search box in the top-right corner of the window to search for a specific type of file. For example, entering *.jpg would display only JPEG image files in the current directory and show you the count of files in the bottom corner of the window.
If you need to use wildcards or count a more specific type of file, use the steps below for counting files in the Windows command line.
Counting files in Microsoft Windows XP
- Open Windows Explorer.
- Browse to the folder containing the files you want to count.
- Highlight one of the files in that folder and press the keyboard shortcut Ctrl+A to highlight all files and folders in that folder. In the Explorer status bar, you'll see how many files and folders are highlighted, as shown in the picture below.
If hidden files are not shown, these files are not selected.
You can also individually count a specific type of file, like only counting image files. Click the type column header to sort the files by type and then highlight the first file type you want to count. Once the first file is highlighted, hold down Shift and while continuing to hold it down, press the down arrow to individually select files. For several files, you can also hold down Shift and press PgDn, to highlight files a page at a time.
If you need to use wildcards or count a more specific type of file, use the steps below for counting files in the Windows command line.
Counting files in Microsoft command line (DOS)
- Open the Windows command line.
- Move to the directory containing the files you want to count and use the dir command to list all files and directories in that directory. If you're not familiar with how to navigate and use the command line, see: How to use the Windows command line (DOS).
As seen above, at the bottom of the dir output, you'll see how many files and directories are listed in the current directory. In this example, there are 23 files and 7 directories on the desktop.
To count a specific type of file in the current directory, you can use wildcards. For example, typing dir *.mp3 lists all the MP3 audio files in the current directory.
To count all the files and directories in the current directory and subdirectories, type dir *.* /s at the prompt.
Counting files in Linux
To list the count of files in Linux, use the ls command piped into the wc command, as shown below.
ls -1 | wc -l
To prevent any confusion, the above command reads ls <dash><the #1> <pipe> ls <dash><the letter l>. This command list files in a bare format, and pipes the output into the wc command to count how many files are listed. When done properly, the terminal should return a single number indicating how many lines were counted and then return you to the prompt.
Realize that this is also counting the ./ and ../ directories.
You can also add the grep command to find a more exact count of the files you want to count, as shown below.
ls -1 | grep ^a | wc -l
In the example above, the command only counts files that begin with the letter "a". The regular expression ^a could be replaced with any valid grep command, or you could replace the letter "a" with another letter.
Counting files in macOS
Open the folder containing the files you want to count. In the bottom-center section of the window, the number of objects in the folder is displayed.