# Batch to find the lowest number in a txt file - PLEASE help!



## xcalibursword (Apr 30, 2012)

Hey,

I've done this about a million times in C++ but I just can NOT seem to wrap my head in batch.
I have a txt with some numbers i.e: 

5
3
8
9

Just need to somehow get 3 out of there.
Can anyone please help out?

Thanks!


----------



## Squashman (Apr 4, 2003)

Your description of your problem is misleading to your thread subject. Do you need the 3 or do you need the lowest number?


----------



## xcalibursword (Apr 30, 2012)

Squashman said:


> Your description of your problem is misleading to your thread subject. Do you need the 3 or do you need the lowest number?


Isnt 3 the lowest number? 
That was just for an example.
I have a list of numbers and I need to ouput the lowest\smallest number.

Thanks!


----------



## Squashman (Apr 4, 2003)

Obviously 3 is the lowest number. But I have learned over the many years of my life to program per the instructions and even then the person who wrote the instructions didn't explain it correctly and means something completely different. In my line of work I can't be wrong. I program data for a living.


```
@echo off
setlocal enabledelayedexpansion

set /p lowest=<numbers.txt

FOR /F "delims=" %%G in (numbers.txt) DO IF %%G LSS !lowest! SET lowest=%%G
```


----------



## xcalibursword (Apr 30, 2012)

Thanks a million man!


----------

