Link to home
Start Free TrialLog in
Avatar of wasabi3689
wasabi3689Flag for United States of America

asked on

how to count files?

I have a directory with its sub -dir. Each sub dir has date with its folder like below. Each date folder has many files

2016
   20160101
   20160102
   20160103
 ........
   20161231


I want to count number of files in each date directory, output to EXCEL. The output should be something like below


2016
   20160101  34
   20160102  230
   20160103  1234
 ........
   20161231   90


How to do this in DOS script
Avatar of NVIT
NVIT
Flag of United States of America image

This works.
Change RootDir to your needs.


@echo off
set RootDir=c:\local\test
for /d %%A in (%RootDir%\*) do (
  for /f "tokens=1" %%a in ('dir "%%A\*" ^| find /i "File(s)  "') do (echo %%~nA   %%a)
)

Open in new window

Avatar of wasabi3689

ASKER

it outputs something else.

Here is what I run

@echo off
set RootDir=c:\local\test
for /d %%A in (%\\test2\NGProduction\FinalDocs\HPMG\Documents_doc_InterfaceProc\2016%\*) do (
  for /f "tokens=1" %%a in ('dir "%%A\*" ^| find /i "File(s)  "') do (echo %%~nA   %%a)
)

pause

Open in new window

also, I want to output to an Excel file
ASKER CERTIFIED SOLUTION
Avatar of NVIT
NVIT
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial