avery_larry's helpful answer does a great job of explaining the fundamental problems with your approach (lexical rather than numerical comparison, numbers that are too large).
If your comparison doesn't need to be accurate down to the byte level, you can try the following approach, which enables a simpler solution:
@echo off setlocal enabledelayedexpansion for /f "delims=" %%a in (' powershell -noprofile -c ^ "[math]::Ceiling((Get-ChildItem -File -Recurse \"C:\XSTOREDB\xstore_data.mdf\" | Measure-Object -Property Length -Sum).Sum / 1mb)" ') do set "foldsize=%%a" :: # 6000000000 bytes is ca. 5722 MB if !foldsize! GTR 5722 ( exit /B 0 ) else ( exit /B 1999 )
Note how the PowerShell command divides the result by 1mb (1 MiB (mebibyte) = 2 ^ 20 = 1,048,576 bytes) and then rounds it up via [math]::Ceiling()
Also note how the embedded " chars. were escaped as \" to ensure that PowerShell sees them.
Finally, note how, as a small optimization, -File was passed to the Get-ChildItem cmdlet in order to skip directories (themselves, not their files), given that directories themselves have no Length property.