Thursday 15 September 2011

Count how many files are in a folder?

Microsoft Windows Vista and 7 users
  1. Open Windows Explorer.
  2. Browse to the folder containing the files you wish to count. As shown in the below picture, in the bottom left portion of the window it will display how many items (files and folders) are in the current directory.
Windows 7 explorer showing count of files
NoticeIf hidden files are not shown, these files will not be counted.
Notice If any file or folder is highlighted, only the selected items will be counted.
Tip Use the search box in the top-right corner of the window to search for a specific type of file. For example, entering *.jpgwould display only JPEG image files in the current directory and show you the count of files in the bottom corner of the window.
Tip If you need to use wildcards or count a more specific type of file, use the below steps for counting files in the Windows command line.

Microsoft Windows XP users
  1. Open Windows Explorer.
  2. Browse to the folder containing the files you wish to count.
  3. Highlight one of the files in that folder and press the keyboard shortcut CTRL + A to highlight all files and folders in that folder. Once all files have been highlighted, in the Explorer status baryou'll see how many files and folders are highlighted as shown in the below picture.
Windows Explorer
Notice If hidden files are not shown, these files will not be selected.
Tip You can also individually count a specific type of file, for example, only counting image files. Click on the Type column header to sort the files by type and then highlight the first file type you wish to count. Once the first file has been highlighted hold down the Shift key and while continuing to hold it down press the down arrow key, to individually select files. If there are a lot of files, you can also hold down the Shift key and press the Page down key, which will highlight files a page at a time.
Tip If you need to use wildcards or count a more specific type of file, use the below steps for counting files in the Windows command line.

www.windowslinux.co.inMicrosoft command line (DOS) users
  1. Open the Windows command line.
  2. Move to the directory containing the files you wish 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 our How to use the Windows command line (DOS) page.
Windows command line listing Desktop files
As can be seen in the above example, at the bottom of the 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.
Tip To count a specific type of file in the current directory, you can use wildcards. For example, typing dir *.mp3 would list all the MP3 audio files in the current directory.
Tip To count all the files and directories in the current directory andsub directories, type dir *.* /s at the prompt.
Linux users

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 ls . This command uses the ls command to 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.
Tip Keep in mind 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 wish to count as shown below.
ls -1 | grep ^a | wc -l
In this above example, the command will only count files that being with the letter a. The regular expression ^a could be replaced with any valid grep command or you could just replace the letter a with another letter.

MacOS users
  1. Open the folder containing the files you want to count.
  2. In that folder you should see at the bottom center of the window how many objects are listed, as shown in the below example picture.
Mac folder count

No comments:

Post a Comment

Do not post irrelevant comments, please!

Browser Name:
Browser Version:
Browser Code Name:
User-Agent: