I have a text file which contains hundreds of items (could be words or sentences) with each item on a line. Now, I need a Software that when given the command, will randomly pick an item from the given list. It should then remove this item from the original list and carry out the same operation on the remaining list for another instance until the list is exhausted. Any luck with such a Software? Thanks in advance.

  • 1
    This is a very specific use-case; some general purpose "randomly read a line until they're all gone" software probably doesn't exist in the normal channels. I'd imagine that the best solution may be to just write a shell script to do this yourself, or have someone else write it for you. But I imagine Excel could be cajoled into doing this as well.
    – dotVezz
    Commented Oct 18, 2017 at 12:56
  • Shell script? could you enlighten me a little... and I must say I agree with what you said that its very specific user-case
    – Gideon
    Commented Oct 18, 2017 at 13:13

2 Answers 2


If you are in a hurry then something like this is easy to use but you would have to remove each selected item from the list manually:

This site will randomly draw each item all at once and give you a list of the results and seems the closest to what you want. You could try searching for other Online Hat Draw Tools see more options:

You could also set something up with excel:

If you do not mind entering the data manually onto an android device ( or iOS ) there are many similar apps to randomly pick something and remove it from the list:

If none of the above meets your needs you could ask a programmer to make you a custom app. The functionality for this would be simple to create excluding a fancy UI.


Just for fun I decided to write a script.

  • Copy this code into a text file named "DrawFromHat.bat".
  • Copy your list of items into a file named "FullHat.txt" in the same directory as DrawFromHat.bat.
  • Double click DrawFromHat.bat to run.
  • Hit enter to keep drawing items from the hat.
  • Or modify the code to draw names without user input.

Here is the code:

@echo off
setlocal EnableDelayedExpansion

if not exist FullHat.txt (
    echo Add a list of items to Fullhat.txt and try again...

::echo Copying FullHat.txt to WorkingHat.txt
copy FullHat.txt WorkingHat.txt >NUL

::Delete Result.txt in prep for new run
del Result.txt >NUL 2>&1

set /p answer=Hit Enter to start drawing items from the hat...

echo *****************START***********************
:: get total number of items in WorkingHat.
set "cmd=findstr /R /N "^^" WorkingHat.txt | find /C ":""
for /f %%a in ('!cmd!') do set number=%%a
echo %number% of items to pick from.

if %number% leq 0 goto workingHatEmpty

:: get random line number between 1 and number of items in WorkingHat.
set /a ran=%random% %% %number%+1
echo %ran% is the selected item number.

:: find the item at the randomly selected line number.
set x=1
set "choice="
for /F "delims=" %%i in (WorkingHat.txt) do (
    if !x!==%ran% (
        :: save it to a variable
        if not defined choice set "choice=%%i"

        :: copy to result.txt
        ECHO %%i>>"Result.txt"
    set /a x=!x!+1
echo You drew item ( %ran% of %number% ):  %choice%

::Delete WorkingHat.txt in prep for creating new one.
del WorkingHat.txt >NUL 2>&1

::Copy items that were not drawn back into WorkingHat in prep for next drawing.
findstr /v /i /G:Result.txt FullHat.txt > WorkingHat.txt

::uncomment this line to continuously draw from the hat.
::goto start

echo *****************END*************************
set /p answer=Hit enter to draw again. 
if "%answer%"=="n" goto end
if "%answer%"=="N" goto end
goto start

echo The hat is empty!


echo See Result.txt for the results.


I only tested it on windows 7. It works by copying all the items from FullHat.txt into a new file WorkingHat.txt. Items are randomly chosen from WorkingHat.txt and moved into Result.txt. WorkingHat.txt is regenerated without the items in Result.txt. It is effectively like drawing names from a hat until they are all gone.

  • 1
    You are a genius buddy, it does exactly what I want it to. Am not really after UI so this is just okay for me. Thanks a lot
    – Gideon
    Commented Oct 19, 2017 at 12:50

Another way to do it is to use this random site I found: https://www.random.org/lists/

It takes lines of text and then returns them in a random order which might be good enough for your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.