[英]windows batch variable's size max
我的批次有问题。 批量测试目录的大小,当目录太大时,删除最旧的文件。
批次:
@echo off
setlocal enabledelayedexpansion
net use T: /d
net use T: \\10.230.78.22\survcam
set dossiure=T:\
set "$max=204010946560"
Echo traitement en cours....
:loop
for /f "tokens=3 delims= " %%a in ('dir %dossiure% ^| find /i "octets"') do (
set $NbBytes=%%a
goto:test
)
:test
If %$NbBytes% GTR %$max% (
for /f "delims=" %%a in ('dir %dossiure% /b/a-d/od') do (
set LeVieux="%dossiure%%%a"
Echo Destruction de : [!LeVieux!]
del "!LeVieux!"
goto:wait
)
)
goto:fin
:wait
rem ping localhost -n 1
goto:loop
:fin
net use T: /d
echo fini
当$ max = 85899345920
没关系(80GiB)
但是当$ max = 204010946560
它比指示的大小(190GiB)增加更多
就像它了解19Gib限制有人知道如何解决它吗?
批处理中的数字变量的最大值为2 ^ 31。
尝试使用Mib计算或使用2个变量(Mb和字节)
但是,由于您的变量都是已知为数字的单个字符串,因此请尝试
set "$$max=000000000000000000000%$max%"
set "$$NbBytes=000000000000000000%$NbBytes%"
if %$$NbBytes:~-18% GTR %$$max:~-18% (
也就是说,给变量加上0
s的前缀,然后比较结果字符串的最后n个字符(我选择了18个)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.