I have the following batch script:
Copied it from internet. Need help to modify the script per my requirement.
@ECHO OFF
IF "%~1"=="" GOTO :EOF
SET "filename=%~1"
SET fcount=0
SET linenum=0
FOR /F "usebackq tokens=1-30 delims=|" %%a IN ("%filename%") DO ^
CALL :process "%%a" "%%b" "%%c" "%%d" "%%e" "%%f" "%%g" "%%h" "%%i" "%%j" "%%k" "%%l" "%%m" "%%n" "%%o" "%%p" "%%q" "%%r" "%%s" "%%t" "%%u" "%%v" "%%w" "%%x" "%%y" "%%z" "%%?" "%%_" "%%@" "%%\"
GOTO :EOF
:trim
SET "tmp=%~1"
:trimlead
IF NOT "%tmp:~0,1%"==" " GOTO :EOF
SET "tmp=%tmp:~1%"
GOTO trimlead
:process
SET /A linenum+=1
IF "%linenum%"=="1" GOTO picknames
SET ind=0
:display
IF "%fcount%"=="%ind%" (ECHO.&GOTO :EOF)
SET /A ind+=1
CALL :trim %1
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO !tmp!
ENDLOCAL
SHIFT
GOTO display
:picknames
IF %1=="" GOTO :EOF
CALL :trim %1
SET /a fcount+=1
echo %tmp%
SET "f%fcount%=%tmp%"
SHIFT
GOTO picknames
I have the following feed file that I supply as parameter to the batch script above.
aa"aaaaa|bbbbbbbb|cccccc
ddddddd|eeeeeeee|ffffff
ggggggg|hhhhhhhh|iiiiii
jjjjjjj|kkkkkkkk|llllll
mmmmmmm|nnnnnnnn|oooooo
Notice that the feed file has double quotes. This breaks the script when I try to run the batch script. plz help. Please help in handling other special characters also.
Also, the script above treats the first line differently from other lines. I want it to treat the first line also as any other line. plz help