Share via


Windows PowerShell: How to Count Files in a Folder or a Directory

Learn a Quick and Easy Way to Count Files in a Folder 

 During your day-to-day tasks, you may need to count the files in a folder on a Windows server or provide full statistics on how many files a folder or contains. This information helps you get better insight into your file structure and facilitates other file management tasks. Instead of checking the number of files and directories manually, you can simply run the PowerShell command provided above and then search through the results to find the particular data you need.

  1. Open the PowerShell ISE → Run the following script, adjusting the directory path:
Get-ChildItem \\pdc\Shared\Accounting -Recurse -File | Measure-Object | %{$_.Count}

2. Review the results:

https://img.netwrix.com/howtos/ps_count_files_report.png

Credits

Original: https://www.netwrix.com/how_to_count_files_in_a_folder.html