My problem is can't split the tilde I/p file: sample data: only has 5 cols where 2nd col value is blank but delims using tilde operator is showing 2nd field value is 3.
Input file:
1~~3~4~5
my actual output is
field 1: 1
field 2: 3
field 3: 4
field 4: 5
field 5:
my expected output should be
field 1: 1
field 2:
field 3: 3
field 4: 4
field 5: 5
my expected output should be field 2 output should be blank. Below code demilits comma. I want similar to do for tilde symbol(~)
Here is my code:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
for /F "usebackq delims=" %%# in (F:\batch\input.txt) do (
pause
set "LINE=%%#"
echo Line is:%%#
setlocal EnableDelayedExpansion
for /F "tokens=1-5 delims=," %%A in (^""!LINE:,="^,"!"^") do (
endlocal
echo Field 1: %%~A
echo Field 2: %%~B
echo Field 3: %%~C
echo Field 4: %%~D
echo Field 5: %%~E
setlocal EnableDelayedExpansion
)
endlocal
)
pause
endlocal
After reading that post in the comment still I am not able to get the exact output. Can you please advise ?