0

when I try "dir" I get:

02/13/2020  03:29 PM    <DIR>          Saved Games
02/13/2020  03:29 PM    <DIR>          Searches
02/16/2020  12:57 PM    <DIR>          Videos
               1 File(s)              0 bytes
              16 Dir(s)  21,887,438,848 bytes free
  <<<<<<<this new line is what I want to delete or disable

I tried commands like findstr "." test.txt > output.txt but they all add that new line at the end.

Thank you

EDIT: I export "dir /B" to a file > output.txt

I need this because another program uses the list, and the last new line crashes it.

The program that loops through that list is hardcoded, so I need to provide it a list without the blank line.

  • 2
    CR/LF is added after *EACH* command output. It's possible to strip it, but why? The solution depends on your use case, do you only show the output or want to store it into a file, do you want to process it with ... ? Can leading spaces be stripped? – jeb Feb 19 '20 at 15:43
  • Please edit the question to include at least one use case. (Why do you need this?) – lit Feb 19 '20 at 16:24
  • Are you trying to run this through a for loop to get the number of bytes free? – SomethingDark Feb 19 '20 at 17:40
  • There is no empty line, the last line simply ends with a CR/LF. Do you need the last line `16 Dir(s) ....` , else you could filter it by using `findstr /V "Dir(s)"` – jeb Feb 20 '20 at 08:35
  • @jeb commands like `cd.` or `set /A 15/5` dont – ScriptKidd Feb 20 '20 at 11:09
  • @HackingAddict0302 `cd.` output no lines at all, but without lines there can't be a line terminator – jeb Feb 20 '20 at 12:11
  • See [Batch File: Removing carriage return from .tsv file](https://stackoverflow.com/questions/32868862/batch-file-removing-carriage-return-from-tsv-file) – ScriptKidd Feb 22 '20 at 02:54

0 Answers0