Batch Script : Space issue with text file to remove

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Rajnishjc_27
Posts: 21
Joined: 16 Aug 2019 23:35

Batch Script : Space issue with text file to remove

#1 Post by Rajnishjc_27 » 22 Aug 2019 04:27

Hi Friends,

I have a data like below in .TXT file

id name Add
1 ; Severe weather - snow In
2 ; ;

now in my 2 id name is blank, now how to check blank field or avoid or length of the of the field in below batch script.

setlocal enabledelayedexpansion
for /F " skip=1 tokens=2 delims=;" %%b in (%file% ) do (
echo %%b
)

pieh-ejdsch
Posts: 240
Joined: 04 Mar 2014 11:14
Location: germany

Re: Batch Script : Space issue with text file to remove

#2 Post by pieh-ejdsch » 24 Aug 2019 07:56

hallo,
use a real token (1st)

Code: Select all

for /F " skip=1 tokens=1,2 delims=;" %%a in (%file% ) do if "%%b" NEQ "" (
  echo %%b
) else echo EMPTY
Phil

Post Reply