Search code examples
command-linetrim

Trimming text files from command line (Windows)


I have a text file which contains several hundred lines e.g.

test.bin:8948549854958

They are all styled like the above file (xxxxxxx.xxx:xxxxxxxxxxxxxx)

Is there any way I could trim all lines e.g. take :xxxxxxxxxxxxxxx of the line, so just to leave xxxxxxx.xxx ?


Solution

  • Trim.bat:

    @FOR /F "tokens=1 delims=:" %%G IN (%1) DO @echo %%G
    

    Usage: trim source.txt > destination.txt

    See here.