Imthedude025

Select Random Name From Input'ed List (Batch)

Sep 26th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2. ::Select Random Name From Input'ed List ::
  3. ::Created by RU$$ [http://russdev.mooo.com/] ::
  4. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  5. @ECHO OFF
  6. @TITLE Pick a random name!
  7. @SETLOCAL
  8. @SETLOCAL EnableDelayedExpansion EnableExtensions
  9. @GOTO GUI
  10.  
  11. :GUI
  12. cls
  13.  
  14. echo ============================================================
  15. echo Current List:
  16. echo ============================================================
  17. for /f "tokens=*" %%a in ('type ListFile.txt') do (
  18. set line=%%a
  19. echo !line! )
  20. echo ============================================================
  21. echo(
  22. echo --Options--
  23. echo 1. Pick A Name
  24. echo 2. Remove All Names
  25. echo 3. Exit
  26. echo(
  27.  
  28. Echo --Input a name to add to the list--
  29. Set /p DIR=Name or Option:
  30.  
  31. SET DIR=!DIR: =_%!
  32. IF /I '%DIR%'=='1' GOTO RANDOM
  33. IF /I '%DIR%'=='2' GOTO DELST
  34. IF /I '%DIR%'=='3' GOTO :eof
  35.  
  36. Echo !DIR! >> ListFile.txt
  37. goto GUI
  38.  
  39. :DELST
  40. cls
  41. DEL ListFile.txt
  42. .>> ListFile.txt
  43. cls
  44.  
  45. Echo STATUS: List Was Deleted.
  46. Echo(
  47.  
  48. Pause
  49. GOTO GUI
  50.  
  51. :RANDOM
  52. SET "TextFile=ListFile.txt"
  53. FOR /f %%a IN ('type "%textfile%"^|find /c /v ""') DO SET /a numlines=%%a
  54. SET /A RandomLine=(%RANDOM% %% %NumLines%)
  55.  
  56. IF "%RandomLine%"=="0" (SET "RandomLine=") ELSE (SET "RandomLine=skip=%randomline%")
  57.  
  58. FOR /F "usebackq tokens=* %RandomLine% delims=" %%A IN (`TYPE %TextFile%`) DO (
  59. SET RNAME=%%A
  60. GOTO COMPLETE
  61. )
  62.  
  63. :COMPLETE
  64. CLS
  65.  
  66. echo ============================================================
  67. echo RESULTS:
  68. echo(
  69. echo Your random name is - %RNAME%
  70. echo ============================================================
  71. echo(
  72.  
  73. pause
  74. goto :EOF
Add Comment
Please, Sign In to add comment