How to Count Files in a Folder with PowerShell, CMD, or File Explorer

This guide shows how to count the number of files in a Windows folder using three different methods – PowerShell, Command Prompt (CMD), and File Explorer.

Requirements

  • Windows Operating System
  • Basic familiarity with command-line interface for PowerShell and CMD methods

PowerShell Method

Count Files in a Folder

Open PowerShell and run the following command to count all the files in a specified folder:

(Get-ChildItem 'C:\path\to\folder' -File).Count

Count Files Recursively in Subfolders

To count files in all subfolders as well, run:

(Get-ChildItem 'C:\path\to\folder' -File -Recurse).Count

CMD Method

Count Files in a Folder

Open Command Prompt and run the following command:

dir "C:\path\to\folder" /A:-D /B | find /v /c ""

Count Files Recursively in Subfolders

For counting files in all subfolders, run:

dir "C:\path\to\folder" /A:-D /S /B | find /v /c ""

File Explorer Method

Simply navigate to the folder whose files you want to count. Then:

  • Select all files: Press Ctrl + A.
  • Right-click and choose Properties: You’ll see the total number of files listed.

Caution

  • Execution Time: Counting files in folders with a large number of files and subfolders may take some time.
  • Permission Requirements: Make sure you have the necessary permissions to access the folder.