0

Let's say I have a file containing the following two lines:

  V_SOME_ID: Number(context.someid),
  V_SOME_NAME: context.somename

How can I write a .bat file to remove the colon and everything after as well as all spaces? Hoping for a result that looks like this:

 V_SOME_ID
 V_SOME_NAME

Everything I have found so far on Google has been for doing this for variables, I have not found a good example that does it line by line for an entire file.

Edit: I need to remove the content line by inclusive of the ":"

Compo
  • 36,585
  • 5
  • 27
  • 39
user68288
  • 702
  • 2
  • 6
  • 27
  • Do each of the lines in your file really begin with two space characters? and do you realy want your ouput to begin each with just one space character? – Compo Aug 02 '23 at 19:35
  • They can start with any number of space characters, I want them to end with no space characters. – user68288 Aug 02 '23 at 19:36
  • 1
    That isn't what your example shows. Anyhow, does this do what you wanted: ```@For /F UseBackQ^ Delims^=:^ EOL^= %%G In ("P:\athTo\MyFile.ext") Do @For /F "Tokens=*" %%H In ("%%G") Do @Echo(%%H```? – Compo Aug 02 '23 at 19:45
  • Thank you @Compo – user68288 Aug 02 '23 at 19:52
  • Just do this: `for /F "delims=: " %%a in (theFile.txt) do echo %%a` Pay attention to the space after the colon! – Aacini Aug 03 '23 at 01:22

0 Answers0