searching for files in folders/subfolders

Microsoft Windows xp professional w/serv...
June 22, 2010 at 21:34:24
Specs: Windows XP
Hi All,

I'm trying to work out how to create a CSV file which will allow me to find out the number of files in a particular directory and any sub-directories, but not as a grand total.

I need it to have the folder structure and then the number of files (including sub-folders)


C:\Level 1\ 10
C:\Level 1\Sub Level 1\ 0
C:\Level 1\Sub Level 1\next level 1\ 5
C:\Level 1\Sub Level 2\ 5
C:\Level 1\Sub Level 3\ 4
C:\Level 1\Sub Level 3\next level 1\ 12

I would like to open this in Excel so that the folder path is column A and the number of files at that level is column B.

Any ideas?

See More: searching for files in folders/subfolders

Report •

June 23, 2010 at 03:16:27
@echo off > %temp%\my.csv & setLocal enableDELAYedeXpansion

pushd c:\files
for /f "tokens=* delims= " %%a in ('dir/b/s/ad') do (
pushd "%%a"
set N=
for /f "tokens=* delims= " %%i in ('dir/b/a-d') do (
set /a N+=1
>> %temp%\my.csv echo.!CD!, !N!

Helping others achieve escape felicity


Report •
Related Solutions

Ask Question