Dos Command to count files with prefix


I have a files outputted to a folder which have a particular suffix, such as:


I would like to be able to in DOS to count them.
Who is Participating?
Gerwin Jansen, EE MVETopic Advisor Commented:
dir /b c:\yourfolder\*201208* | find /c "201208"
Steve KnightIT ConsultancyCommented:
dir 201208*.* /b /a-d | find /v "" /c

does bare dir listing of files, uses find to find all non-blank lines and count them.


dir 201208*.* | find "File(s)"


dir /s c:\{Folder with files to search}\*.* | find /c "201208"

I assume you aren't concerned the path of the files you just want to find the files that contain the mentioned string and count them.
Steve KnightIT ConsultancyCommented:
My first post was for when I read your question as "prefix" of course.  Use gerwinjansen *201208* function for the dir command instead.

If you want to get the answer into a variable you can use something like:

@echo off
for /f %%a in ('dir *201208* /b /a-d ^| find /v "" /c') do set answer=%%a
echo There are %%a files
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.