@ECHO OFF SETLOCAL EnableDelayedExpansion CALL :DisplayNumber Number "000 0123 456 789" ECHO !Number! ECHO. FOR /L %%A in (0,1,2) DO FOR /L %%B in (9,-1,0) DO ( SET Val=%%B!Val! CALL :DisplayNumber Number "!Val!" ECHO !Number! ) PAUSE EXIT :DisplayNumber [1=Result Var Name] [Val] SETLOCAL CALL :CleanNb Nb "%~2" SET UnitNb=0 SET Unit=[UN-DEFINED UNIT] :DisplayNumber1 IF defined Nb SET digit=%Nb:~-3% SET /a UnitNb+=1 SET Result2=!Result1! SET Result1=!digit! IF DEFINED Result2 (SET Result=%Result1%.%Result2%) ELSE (SET Result=%Result1%) SET Nb=%Nb:~0,-3% IF DEFINED Nb GOTO DisplayNumber1 FOR /F "tokens=%UnitNb% delims=," %%A IN ("B,KB,MB,GB,TB,PB,EB,ZB") DO SET Unit=%%A ENDLOCAL & SET %~1=%Result% %Unit% GOTO :eof :CleanNb IF "%~2" == "" SET %~1=0 & EXIT /b SETLOCAL SET Nb=%~2 SET Nb=%Nb: =% :CleanNb2 IF "%Nb:~0,1%" EQU "0" ( SET Nb=%Nb:~1% GOTO CleanNb2 ) ENDLOCAL&SET %~1=%Nb% EXIT /b
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.