I'm trying to write a script that checks if the size of a file is greater than 0 and if so, prints "greater". I looked at this question and got some good ideas. I tried to implement what the second answerer answered, but it's not working properly.
This is what I have so far:
for %%i in (*.txt) do (
set size=0
set /A size=%%~zi
echo %%i %size%
if %size% GTR 0 echo greater
)
When I try this, it keeps giving me the same size for all the files, even though I know that one of them is different. When I remove the set size=0
, if the file size is 0, it gives an error 0 was unexpected at this time.
Any ideas about what I'm doing wrong?