how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

#1 Post by nnnmmm » 02 Oct 2024 19:58

F9.TXT has
1
2
3

5

7
8

-------------------------------------------------------------
SET K1=F9.TXT

REM these two lines just below are not from me, you may ignore them, cause i dont understand ^ well
For /F tokens^=*^ delims^=^ eol^= %%I in ('TYPE "%K1%"') do echo. %%I
For /F tokens^=*^ delims^=^ eol^= %%I in ("C:\F9.TXT") do echo. %%I

REM --------------------------------------------------------
SetLocal EnableExtensions EnableDelayedExpansion

FOR /F "DELIMS=" %%V IN ('TYPE "%K1%"') DO (
SET VV=%%V
ECHO !VV!
)
ECHO.
FOR /F "Tokens=*" %%V IN ('TYPE "%K1%"') DO (
SET VV=%%V
ECHO !VV!
IF /I "!VV!"=="" ECHO.
IF /I "!VV:~0!"=="" ECHO.
PAUSE

but this batch displays
1
2
3
5
7
8

how do i make the empty lines as output as well as they were intended
all 4 for do loops do not display empty lines
Last edited by nnnmmm on 03 Oct 2024 00:59, edited 1 time in total.

miskox
Posts: 624
Joined: 28 Jun 2010 03:46

Re: how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

#2 Post by miskox » 02 Oct 2024 22:54

Maybe:

Code: Select all

type f9.txt
Saso

nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

Re: how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

#3 Post by nnnmmm » 03 Oct 2024 00:57

i need to put corrected line numbers and control its contents, i left them out to show my problem at the moment
i need empty lines to group them in a way

these will be added later
SET /A CC=!CC!+1
IF !CC! GEQ 1 IF !CC! LEQ 9 SET DD= !CC!
IF !CC! GTR 9 SET DD=!CC!

IF /I "!VV:~0,10!"=="http://www" (SET C1=1)&(ECHO [32m!DD! !VV:~11,%DS2%![0m)
IF /I "!VV:~0,11!"=="https://www" (SET C1=1)&(ECHO [31m!DD! !VV:~12,%DS2%![0m)
IF /I "!VV:~0,9!"=="ftp://ftp" (SET C1=1)&(ECHO [35m!DD! !VV:~10,%DS2%![0m)
IF /I "!C1!"=="0" (ECHO [36m!DD! !VV:~7,%DS2%![0m)

Lucky4Me
Posts: 23
Joined: 21 Oct 2020 06:33

Re: how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

#4 Post by Lucky4Me » 03 Oct 2024 08:25

This is your f9.txt

Code: Select all

1
2
3

5

7
8
change the empty lines with the ALT+08 char (BackSpace) and run

For /f "tokens=*" %%a in ('type %k1%') do echo.%%a

nnnmmm
Posts: 141
Joined: 26 Aug 2017 06:11

Re: how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

#5 Post by nnnmmm » 03 Oct 2024 20:43

>>change the empty lines with the ALT+08 char (BackSpace)
i cant use ALT+08 as the end of line marker,
because i am already using "-" as a marker for a temporary improvisation, "-" is easier than ALT+08
thanks for trying to help
it seems no-go, i will adapt using "-"
i will close this issue, i may ask this again maybe few years later

1
2
3
-
5
-
7
8

miskox
Posts: 624
Joined: 28 Jun 2010 03:46

Re: how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

#6 Post by miskox » 03 Oct 2024 21:57

If you can use external tools: gsar maybe? you replace CRLFCRLF with something like '#' (or another character you don't have in an input file (you mention '-')).

Saso

Eureka!
Posts: 137
Joined: 25 Jul 2019 18:25

Re: how do i display empty lines with maybe DELIMS and TOKENS for TYPE command?

#7 Post by Eureka! » 10 Oct 2024 09:52

Or ...

Use FINDSTR with line numbering and work from there:

Code: Select all

T:\>findstr /n /r "^" f9.txt
1:1
2:2
3:3
4:
5:5
6:
7:7:5\;5:6
8:8
9:

T:\>for /f "usebackq tokens=1,* delims=:" %i in (`findstr /n /r "^" f9.txt`) Do @echo __%j__
__1__
__2__
__3__
____
__5__
____
__7:5\;5:6__
__8__
____

T:\>

Post Reply