Search code examples
windowsbatch-fileduplicatesfindstr

Get a list of IN persons


I have a file that have many lines and I want to be able, in a batch file, to echo all the lines of the persons that are IN now...

My text file is like this :

LEDEE           IN 2016-07-11 07:49:59                                                   
STEPHAN         IN 2016-07-11 07:56:14                                                   
NADIAB          IN 2016-07-11 07:58:30                                                   
ANGEE           IN 2016-07-11 07:58:59                                                   
STEPHAN         OUT 2016-07-11 08:05:25                                                   
STEPHAN         IN 2016-07-11 08:05:29                                                   
ANGEE           OUT 2016-07-11 08:06:05                                                   
ANGEE           IN 2016-07-11 08:06:11                                                   
ANGEE           OUT 2016-07-11 08:16:11                                                   
JOHN            IN 2016-07-11 08:44:42                                                   
PAUL            IN 2016-07-11 08:48:01                                                   
JOHNNY          IN 2016-07-11 08:49:26                                                   
PABLO           IN 2016-07-11 08:49:41 

I want to be able to echo a list of all the persons that are IN now. The result should be :

LEDEE
STEPHAN
NADIAB
JOHN
PAUL
JOHNNY
PABLO

Is this possible ?

Thanks


Solution

  • to give you a start:

    @echo off
    setlocal EnableDelayedExpansion
    for /f "tokens=1,2" %%a in (text.txt) do set _%%a=%%b
    echo ---- current status:
    for /f "tokens=1 delims=_" %%x in ('set _ ') do echo %%x
    echo ---- People IN:
    for /f "tokens=1 delims=_=" %%x in ('set _ ^|find "=IN"') do echo %%x
    echo ---- People OUT:
    for /f "tokens=1 delims=_=" %%x in ('set _ ^|find "=OUT"') do echo %%x