I have a delimited file like below:
Field 0|Field 1|Field 2|Field 3|Field 4|Field 5 June 27 2017|5466|28998|52|3175507|1144121044
My requirement is if any of the above field is empty in .csv file, I need to print the name of the field that is empty and later email the output details saying this field is empty.
I tried below code but failing at last step to check if empty/NULL, pass value to another variable.
setlocal enabledelayedexpansion
@echo off
for /f "tokens=*" %%X in (TEMP.csv) do (
set "work=%%X"
:: fill empty fields with "#NUL#" ...
:: but do it twice, just in case consecutive fields are empty
for /l %%j in (1,1,2) do set "work=!work:||=|#NUL#|!"
for /F "tokens=1,2,3,4,5,6* delims=|" %%i in ("!work!") do (
echo first is %%i
echo second is %%j
echo third is %%k
echo fourth is %%l
echo fifth is %%m
echo sixth is %%n
echo -------------
)
)
|or containing||; or …if "%%n"=="".