top of page

Get Counts of Files in Multiple Subdirectories


Today at work I used a batch file with the XCOPY command to copy a large number of files into a few hundred different subdirectories. I wanted to confirm that each subfolder had a certain number of files copied into it, but I didn't want to take the trouble of parsing through the results of a standard dir command (such as "dir /b /s /a-d >list.txt") which would generate a complete list of file paths for all files in a directory.

I was able to devise a command which gave me the path of each subdirectory followed by the number of files in it. See this command:

dir /a /s | findstr "Directory File(s)"

Adding a pipe | after the dir command followed by the findstr command filters the results for the strings listed in the parentheses. We get just the parts of the results we want to focus on.


Sean O'Shea has more than 20 years of experience in the litigation support field with major law firms in New York and San Francisco.   He is an ACEDS Certified eDiscovery Specialist and a Relativity Certified Administrator.

​

The views expressed in this blog are those of the owner and do not reflect the views or opinions of the owner’s employer.

​

If you have a question or comment about this blog, please make a submission using the form to the right. 

Your details were sent successfully!

© 2015 by Sean O'Shea . Proudly created with Wix.com

bottom of page