how to get the floating variable in a string?

November 1, 2016 at 07:45:53
Specs: Windows 64, Core i7 2GHz/16GB
Hi all,
in my input text file I have a string:


dActualMeasTimeRfBl_Msec = 25.82
I want to write a batch file to get the 25.85 but all I have tried gives me 25. I want to use findstr/rc or findstr/c:

for /f "tokens=3 delims=. " %%A in (
'findstr /rc:sed "??????" "E:\inputt.txt"'
) do echo %%A>>E:\output.csv
Does anyone know what should I replace with question marks to get 25.82?

Thanks for any help!
Ela

message edited by elaheh


See More: how to get the floating variable in a string?

Reply ↓  Report •


#1
November 1, 2016 at 09:24:23
::======  script starts here  ===============
:: 
:: floater.bat  2016-11-01 23:13:04.56
@echo off & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=3 delims= " %%a in ('find "dActualMeasTimeRfBl_Msec" ^<myfile') do (
set V=%%a
)
echo V is set to !V!
goto :eof

::======  script ends here  =================

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

M2 Get custom script or take private lessons


Reply ↓  Report •

#2
November 4, 2016 at 08:30:41
@ Mechanix2go thanks for your reply! do you know how can I include your reply to the following batch file I have?

setlocal EnableDelayedExpansion

for /f "tokens=1,2,3* delims=;" %%a in (inputtest.txt) do (
REM create token file
echo.%%a>current.tok

REM run your function
function -lv D:\%%b.edb current.tok >out.txt

REM get relevant output
for /f %%y in ('findstr /C.........................') do SET RESULT=%%y

REM write output
echo.%%a;%%b;%%c;!RESULT!>>D:\MIDEA\outputtest.txt
)
GOTO :EOF


Reply ↓  Report •

#3
November 4, 2016 at 09:08:55
what is this:

function -lv D:\%%b.edb current.tok >out.txt

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

M2 Get custom script or take private lessons


Reply ↓  Report •

Related Solutions

#4
November 4, 2016 at 09:25:13
@Machanix2Go I'm working with a tool which is exactly the same as windows cmd and this function is a part of that

Reply ↓  Report •

#5
November 7, 2016 at 03:32:09
@Machanix2Go any idea about replacing your answer in my problem?

Reply ↓  Report •

#6
November 7, 2016 at 04:37:48
I have no idea what's going on with you.

'function' is not recognized as an internal or external command,
operable program or batch file.

If you have a file from which you're trying to set vars, post a useful chunk of the file.

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

M2 Get custom script or take private lessons


Reply ↓  Report •

#7
November 7, 2016 at 14:58:10
elaheh: for /f "tokens=3 delims=. " %%A in
If you want "25.82", then you need to not tell FOR to stop at the dot.
for /f "tokens=3 delims= " %%A in

How To Ask Questions The Smart Way


Reply ↓  Report •

#8
November 9, 2016 at 05:56:24
maby this works:

for /f "tokens=3,4 delims=. " %%a in (E:\inputt.txt) do echo %%a.%%b>>"E:\output.csv"

message edited by hidde663


Reply ↓  Report •

#9
November 10, 2016 at 01:40:43
I'll go out on a limb here and venture that this won't make any more sense after 8 more replies

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

M2 Get custom script or take private lessons


Reply ↓  Report •

Ask Question