Solved Counting the number of a specific files in a folder

October 2, 2012 at 10:11:47
Specs: Windows 7
Hello,
I am trying to count the number of .bin files in my folder that include a particular name pattern. I basically need to count how many such files I have for each name type.
For instance in my folder I have files like

Query.1.bin
Query.2.bin
Query.3.bin
and the response should be 3.
I have
set count=0
set pattern=Query.%%?%%.bin
for /f %%i in ('dir /b /a-d %pattern% ^| find /c /v ""') do @call set count=%%i

but my code does not recognize "?" and doesn't replace it with numbers and I get 0 in response.

I would really appreciate it if you can give some help on this.

Best
P.A.


See More: Counting the number of a specific files in a folder

Report •

#1
October 2, 2012 at 11:22:18
✔ Best Answer
@echo off
set #=0
set mask=Query.?.bin
for /f %%i in ('dir /b %mask%') do set /a #+=1
echo %#%

Tony


Report •
Related Solutions


Ask Question