0

Can you help me please, I would like to create batch for count number of file start with key word "MM_" in this path.

D:\>dir /o | find "MM_"
27/06/2017  01:14 PM             1,592 MM_170613.csv
27/06/2017  01:14 PM             1,376 MM_170614.csv
27/06/2017  01:13 PM             2,223 MM_170615.csv
27/06/2017  01:12 PM             2,241 MM_170616.csv
27/06/2017  01:11 PM             2,497 MM_170617.csv

I have use command as Stephan provide as follow detail

@ECHO OFF C: cd "C:\MyDir" set cntAAA = dir /b *MM_*|find /c /v "" echo %cntAAA%

Result is show

0 echo off

Somebody can help?

  • 1
    `find /?` states a `/c` parameter to count... `dir /b *MM_*|find /c /v ""` – Stephan Jun 27 '17 at 09:20
  • You need [`for /F`](http://ss64.com/nt/for_cmd.html) to capture the output of a command (line)... – aschipfl Jun 27 '17 at 11:57
  • 1
    Possible duplicate of [Capture output command CMD](https://stackoverflow.com/questions/14646575/capture-output-command-cmd) – aschipfl Jun 27 '17 at 11:58

1 Answers1

0

Try this instead:

@Echo Off
CD /D "C:\MyDir"
Set "cntAAA=Dir/B "MM_*.csv"|Find /C /V """ 
%cntAAA%
Pause
Compo
  • 36,585
  • 5
  • 27
  • 39