Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file Count within folders of specific name  (Read 4755 times)

0 Members and 1 Guest are viewing this topic.

mrchip

    Topic Starter


    Newbie

    • Experience: Experienced
    • OS: Windows 10
    Batch file Count within folders of specific name
    « on: June 12, 2019, 04:06:07 AM »
    Hi All,

    Can anyone help me on a Batch file code that would count a specific filename ?

    I already know how to count number of files within a folder but i dont know how to incorporate it on a specific filename.

    @echo off
    for /f %%A in ('dir ^| find "File(s)"') do set cnt=%%A

    Sample Filename EGRHI-Tenant1-01061219.csv = 061219 is the date of the sales file (not the date of the day)

    something like count all files ?????-??????-??06??19.csv

    I need to count all files on a monthly basis for example how many files on 0619.

    If theres a blank that would ask me what month and year the better.

    Many thanks

    mrchip

      Topic Starter


      Newbie

      • Experience: Experienced
      • OS: Windows 10
      Re: Batch file Count within folders of specific name
      « Reply #1 on: June 12, 2019, 09:18:25 PM »
      Anyone ?

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Batch file Count within folders of specific name
      « Reply #2 on: June 13, 2019, 09:13:31 AM »
      There is no error checking for two digit responses to the prompts, but Ill leave that to you.

      Code: [Select]
      @echo off
      set /p mm=Enter Month:
      set /p yy=Enter Year:
      for /f %%A in ('dir *%mm%??%yy%.csv ^| find "File(s)"') do set cnt=%%A
      echo %cnt%

      You can remove the last line. It was used it for testing.

      Happy Coding  8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein