Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for min.bat

(view source code of min.bat as plain text)

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. IF "%~2"=="" GOTO Syntax
  4.  
  5. SETLOCAL ENABLEDELAYEDEXPANSION
  6. SET Min=%~1
  7. FOR %%A IN (%*) DO (
  8. 	ECHO.%%~A| FINDSTR /R /I /C:"[^0-9-]" >NUL
  9. 	IF NOT ERRORLEVEL 1 (
  10. 		ENDLOCAL
  11. 		GOTO Syntax
  12. 	)
  13. 	IF %%~A LSS !Min! SET /A Min = %%~A
  14. )
  15. ECHO.%Min%
  16. ENDLOCAL & SET Min=%Min%
  17. EXIT /B 0
  18.  
  19.  
  20. :Syntax
  21. ECHO.
  22. ECHO Min.bat,  Version 1.00 for Windows NT4+
  23. ECHO Returns the lowest from a list of values on the command line
  24. ECHO.
  25. ECHO Usage:  MIN  num1  num2  [ num3  [ num4 ... ] ]
  26. ECHO.
  27. ECHO Notes:  The lowest value is displayed on screen and stored in an environment
  28. ECHO         variable %%Min%%.
  29. ECHO         Works with (signed) integers only, size limited by OS version.
  30. ECHO.
  31. ECHO Written by Rob van der Woude
  32. ECHO http://www.robvanderwoude.com
  33.  
  34. IF "%OS%"=="Windows_NT" EXIT /B 1
  35.  

page last uploaded: 2017-08-21, 14:26