That other solution is grotesque! For the rest of the world trying to solve the same problem, try this:
for /R %dir% %%F in (*) do ( set /a size=!size!+%%~zF )
- "for /R %dir%" means loop recursively through the directory dir.
- %%F is the name of the variable
- in (*) means "match any filename". You could put something else here, like "in (*.jpg)" if you only wanted to know the total size of the pictures in a directory.
- set /a size indicates that the value to the right of the = is an arithmetic expression that needs to be evaluated
- !size! is like %size% but ! indicates you want to use delayed expansion
- %%~zF gets the size in bytes of the file %%F
I recommend http://ss64.com/nt/
as references for writing batch files.