[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

Dos Command to count files with prefix

Hi,

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

 201208

I would like to be able to in DOS to count them.
0
wilflife
Asked:
wilflife
  • 2
4 Solutions
 
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.

Also

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

hth

Steve
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
dir /b c:\yourfolder\*201208* | find /c "201208"
0
 
erobbyCommented:
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.
0
 
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
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now