Get Total No of Files and Total File Size in DVD/CD Media

Few months ago, I was preparing some statistics for data migration.

All data are stored in the DVD disc and I need to calculate total no of files and total data size capacity of each of the DVD disc.

There are more than 100 of discs.

I’m not keen to uses Windows Explorer to browse each media and copy down the info. This manual works is not productive.

The good part is all data are saved in same directory structure in the DVD disc.

For example:


So, I wrote this simple batch file.

set PROGDIR=C:\CheckDVD\

if errorlevel 1 goto ERROR1
if errorlevel 0 goto CHECKDVD

for /f %%a in (%PROGDIR%\DVDLABEL.DAT) do set DVDLABEL=%%a

for /f “tokens=1-4” %%a in (‘dir %DVDDRIVE%\%dvdlabel%\DATA\^| findstr File’) do set FileSize=%%a %%b %%c %%d
echo %DVDLABEL% %FileSize% >> DVDLIST.txt
goto END

echo Drive %DVDDRIVE% Read Error
goto END

echo Ejecting Disc in drive %DVDDRIVE%\%DVDLABEL%
ejectcd.exe %DVDDRIVE%
set FileSize=

You need to change DVDDRIVE as your DVD Drive letter. Also, I created a directory CheckDVD place in drive C and set as PROGDIR.

The output is save in DVDLIST.txt

20060101 104 File(s) 2,556,225,275 bytes
20060102 83 File(s) 2,558,522,935 bytes
20060103 158 File(s) 2,555,870,591 bytes
20060104 107 File(s) 2,555,048,029 bytes
20060105 247 File(s) 2,555,837,471 bytes
20060106 71 File(s) 2,559,812,985 bytes
20060107 16 File(s) 2,343,327,650 bytes
20060108 96 File(s) 2,549,281,457 bytes
20060109 61 File(s) 2,555,356,447 bytes
20060110 121 File(s) 2,556,352,685 bytes
20060111 76 File(s) 2,555,353,270 bytes
20060112 96 File(s) 2,583,055,688 bytes
20060113 136 File(s) 2,551,724,113 bytes

First colume is Directory name, follow by Total No of Files and Total Sizes of the directory.

External tool required:
ejectcd.exe – a freeware for Windows 95/98/Me/NT4/2000/XP.
Downlaod from Eject-CD Website.

Posted in DOS Batch Tagged with:

Leave a Reply