views:

219

answers:

3
REM Detect how many files are on the C: drive
dir /s /b C:\ |find /c "\" > NUMfiles.###
set /p count1=<NUMfiles.###

##### TEMP FILES DELETED HERE, RUN CCLEANER, RUN MBAM, ETC #####

REM Calculate Total Files Deleted
dir /s /b C:\ |find /c "\" > NUMfiles.###
set /p count2=<NUMfiles.###
set /a count3=%count1% - %count2%
echo Number of files removed: %count3%

This doesn't seem to be giving me an accurate reading. Can anyone help? I do a manual check via command line using the 'dir /s /b C:\ |find /c "\"' before the script, and at the end. And the output from '%count3% isn't accurate from my subtraction from the manual checks. Hope you understand my question.

+1  A: 

Iterating over your entire C:\ partition is likely to fail - there could be a lot of stuff there, including %TEMP%. You aren't going to get reliable results this way.

snemarch
A: 

If you must iterate on the all content, this command line might be more precise to list the number of files (files, not directories):

dir /a /s /OG C:\ |find /v "<DIR>" | find /c "M "

Off course, this assume a dir does display 'AM ' or 'PM '.

If it does not, the following should works better:

dir /a /s /OG C:\ |find /v "<DIR>" | find /c "/"
VonC
I don't think that is correct. I got a return value of 8630? I'm sure there is more files than that on the C: drive. Thanks for your help =)
A: 

Yes, as snemarch montined, the fact that you list everything and temporary files could as well be added/deleted by another process meanwhile invalidate the entire effort.

On a side note, adding "/a-d" to the "dir" command would remove the directories from being listed, thus not needing VonC's "find /v "" addition to the process, if you insist on checking files only.

Could you not check file while they get deleted instead? Not sure what you use this for but you definately need to rethink the way from source, the deleting part.

My suggestion.

Jay