Question : Files count via batch file

I am not a coder but I think this bat file comes close to what I am trying to accomplish.  (Please see related solution)
I have a folder on a network drive named P:\Contractor Work and each contractor has folder in this main folder like so P:\Contractor Work\Brad Pitt
In each contractor folder they weekly dated folder for each Friday when files are turned in like so P:\Contractor Work 11-11-2009
I need to create a bat file to look into each contractor folder and list the total number of pdf files, xls files, and the total number of new files since the previous Friday.  Please let me know if I am correct in thinking that this bat file comes close.  Thank you in advance.

User              Total PDF Files       Total XLS Files   New Files  Total Files
Brad Pitt         2                                  5                        2               7
John Doe       5                                  7                        5              12

Answer : Files count via batch file

Paste the script below into a text file with a .cmd extension.  Customize the value of the root variable on line 4 with the location of the folder containing the contractors' folders.  Running the script will write output to a comma-delimited text file.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
@echo off
setlocal enabledelayedexpansion
 
set root=P:\Contractor Work
set report=report.csv
 
echo Total PDF Files,Total XLS Files,New Files,Total Files > "%report%"
 
for /f "tokens=*" %%G in ('dir "%root%" /a:d /b') do (
 set pdfcount=0
 set xlscount=0
 set totalcount=0
 set newcount=0
 
 for /f %%H in ('dir "%root%\%%G\*.pdf" /a:-d /b /s') do set /a pdfcount+=1
 for /f %%H in ('dir "%root%\%%G\*.xls" /a:-d /b /s') do set /a xlscount+=1
 for /f "tokens=*" %%H in ('dir "%root%\%%G" /a:d /b /o:d /t:c') do set newest=%%H
 for /f %%H in ('dir "%root%\%%G\!newest!" /a:-d /b /s') do set /a newcount+=1
 for /f %%H in ('dir "%root%\%%G" /a:-d /b /s') do set /a totalcount+=1
 
 echo "%%G",!pdfcount!,!xlscount!,!newcount!,!totalcount! >> "%report%"
)
Random Solutions  
 
programming4us programming4us