:set /a nFileSize=0
(
call :getFileSize D:\test1\sendszl2data\20111031\SZSEL2-20111031.tar.gz
call :getFileSize D:\test1\sendszl2data\20111031\SZSEL2-20111031.tar.gz
echo %nFileSize%
)
(
call :getFileSize D:\test1\sendszl2data\20111031\SZSEL2-20111031.tar.gz
echo %nFileSize%
)
pause
:获取指定文件的大小
:getFileSize
@echo off
set strFilePath=%1%
set /a nFileSize=0
for /f "delims=" %%i in ('dir %strFilePath% /s/b') do set nFileSize=%%~zi
echo infun %nFileSize%
goto :EOF
为什么第一次结果是错的?