0

I have a batch file that is supposed to echo words from each line in a .dll file. It works fine, I just don't know how to add numbers or letters to the front of the output. This might be confusing so I will show you what I'm working with.

Here is my for loop:

    for /f %%b in (log.dll) do echo %%b

"log.dll" looks like this:

    test
    rick
    sanchez

The output of the batch file looks the same:

    test
    rick
    sanchez

This is all well and good, but how could I make the output look like this:

    1 test
    2 rick
    3 sanchez

It doesn't have to be exactly like that, but I want it to look similar. How could I do this, and is it even possible to do this?

  • 3
    Pretty much a duplicate: https://stackoverflow.com/q/7522740/1531971 (Among others; you want to either access the "index" of the loop, or maintain a counter and display that.) –  Oct 01 '18 at 18:35
  • If you don't care about the format of the output then this can easily be accomplished with the `FIND` and `FINDSTR` commands. `findstr /n "^" log.dll` or `find /v /n "" log.dll` – Squashman Oct 01 '18 at 20:58
  • 3
    `.dll` files are binary files - they don't have **lines**, IMO best you can do is use strings.exe from sysinternals.com to extract strings of a minimal length. –  Oct 01 '18 at 21:20
  • 2
    @LotPings - This seems like one of those deliberately misnamed files that's actually a text file. I usually see people use .dat instead. – SomethingDark Oct 02 '18 at 02:50
  • Thank you all for your help! – Carter H Oct 02 '18 at 12:23

0 Answers0