Solved how can we drop equal sign from a variable?

October 23, 2016 at 11:36:09
Specs: Windows 64, Core i7 2GHz/16GB
Hi all,
I have an input.txt file which a part of it looks like the following:

tr=min;
te=min;

I wrote a batch file and at the end the goal is to get tr min and te min (without equal signs). My batch file is:

setlocal EnableDelayedExpansion

for /f "tokens=1,2,3* delims=;" %%a in (E:\input.txt) do (
echo.%%a>current.tok
echo.%%a;!RESULT!>>hodi.txt

)
GOTO :EOF

but this returns tr=min; and te=min; which I need only for my current.tok file, but as input in my hodi.txt file I only need tr min and te min.
Can anyone help me in this?
Thanks in advanced.
Elaheh


See More: how can we drop equal sign from a variable?

Reply ↓  Report •


✔ Best Answer
October 24, 2016 at 07:03:49
::====== script starts here ===============
::
:: trte.bat 2016-10-24 14:29:27.82
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in (myfile) do (
call :sub1 %%a
) >> NEWFILE
goto :eof

:sub1
echo %1 %2
goto :eof
::====== script ends here =================

=====================

M2 Get custom script or take private lessons



#1
October 23, 2016 at 12:28:55
It depends on what your input file actually looks like, but you could try delims==;.

How To Ask Questions The Smart Way


Reply ↓  Report •

#2
October 23, 2016 at 14:20:17
@Razor2.3 Thanks but delims==; will return tr;min and te;min

Reply ↓  Report •

#3
October 23, 2016 at 16:25:15
No, it won't?

Given your input and my delims, the first pass will render:
%%a=tr
%%b=min
%%c=<empty>
%%d=<empty>

The second pass will end up as:
%%a=te
%%b=min
%%c=<empty>
%%d=<empty>

How To Ask Questions The Smart Way


Reply ↓  Report •

Related Solutions

#4
October 24, 2016 at 00:39:04
::====== script starts here ===============
::
:: trte.bat 2016-10-24 14:29:27.82
@echo off & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in (myfile) do (
call :sub1 %%a
)
goto :eof

:sub1
echo %1 %2
goto :eof
::====== script ends here =================

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

#5
October 24, 2016 at 05:41:57
@Mechanix2go thanks,your answer works the way I want,and how should I get it as the output.txt file?

Reply ↓  Report •

#6
October 24, 2016 at 07:03:49
✔ Best Answer
::====== script starts here ===============
::
:: trte.bat 2016-10-24 14:29:27.82
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in (myfile) do (
call :sub1 %%a
) >> NEWFILE
goto :eof

:sub1
echo %1 %2
goto :eof
::====== script ends here =================

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •


Ask Question