Dos Command to count files with prefix

Posted on 2012-09-19
Last Modified: 2012-10-01

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.
Question by:wilflife
    LVL 43

    Assisted Solution

    by:Steve Knight
    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)"


    LVL 37

    Accepted Solution

    dir /b c:\yourfolder\*201208* | find /c "201208"
    LVL 2

    Assisted Solution

    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.
    LVL 43

    Assisted Solution

    by:Steve Knight
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
    Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now