math - repeating variable issue in windows batch file -
i have following code in batch file:
set /p user="enter username: " %=% cd w:\files @echo off setlocal enabledelayedexpansion set /a value=0 set /a sum=0 set /a vala=0 /r %1 %%i in (*) ( set /a value=%%~zi/1024 set /a sum=!sum!+!value! set /a sum=!sum!/1024 ) @echo size of "files" is: !sum! mb @echo off /r %1 %%i in (*) ( set /a sum=!sum!/1024 set /a vala=!sum! ) @echo size of "files" is: !sum! gb cd w:\documents , settings\%user%\desktop @echo off setlocal enabledelayedexpansion set /a value=0 set /a sum=0 set /a valb=0 /r %1 %%i in (*) ( set /a value=%%~zi/1024 set /a sum=!sum!+!value! set /a sum=!sum!/1024 ) @echo size of desktop is: !sum! mb @echo off /r %1 %%i in (*) ( set /a sum=!sum!/1024 set /a valb=!sum! ) @echo size of desktop is: !sum! gb
there few other folders checks, should idea.
i output:
c:\users\pprescott\desktop>cd w:\files size of "files" is: 215 mb size of "files" is: 0 gb size of desktop is: 215 mb size of desktop is: 0 gb size of favorites is: 215 mb size of favorites is: 0 gb size of documents is: 215 mb size of documents is: 0 gb total size is: 0 mb total size is: 0 gb press key continue . . .
this designed count folder size on old xp machine prepare data transfer. xp machine mapped drive w.
try remove for /r
parameter %1
:
for /r %%i in (*) (
try code:
@echo off &setlocal /r "w:\files" %%i in (*) set /a asum+=%%~zi set /a sum=asum/1048576 echo size of "files" is: %sum% mb set /a sum=asum/1073741824 echo size of "files" is: %sum% gb /r "w:\documents , settings\%user%\desktop" %%i in (*) set /a asum+=%%~zi set /a sum=asum/1048576 echo size of "desktop" is: %sum% mb set /a sum=asum/1073741824 echo size of "desktop" is: %sum% gb
Comments
Post a Comment