Solved What is causing missing operand error in this code?

April 15, 2017 at 09:20:32
Specs: Windows 10
The code worked just fine yesterday... I think

setlocal enabledelayedexpansion
set /a value=0
set /a sum=0
for /r %1 %%i in (*) do (
set /a value=%%~zI/1024
set /a sum=!sum!+!value!
)
echo %sum%
pause

message edited by eax02


See More: What is causing missing operand error in this code?

Reply ↓  Report •


#1
April 15, 2017 at 15:45:30
for /r %1 %%i in (*) do (
set /a value=%%~zI/1024

You sure it worked before? Case matters here, and you've mixed lowercase and uppercase "i"s.

How To Ask Questions The Smart Way


Reply ↓  Report •

#2
April 15, 2017 at 23:30:23
✔ Best Answer
And you can simplify the math:
===========================
@echo off

setlocal enabledelayedexpansion
set sum=
for /r %1 %%i in (*) do (
set /a sum+=%%~Zi/1024
)
echo !sum!

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •
Related Solutions


Ask Question