我有一个bat文件,读取logging列表并从每行中提取一个数字。 然后将这些数字写入另一个文本文件,然后从这里计算出总数值是多less,在读取数字时将前导0删除。
这一切工作正常,但我似乎无法得到正确的是,因为这个值是一个价格,它需要有2个小数点。 目前它打印到文件为2971480 ,但我需要它为29714.80 。 有没有办法在bat文件中做到这一点?
我使用的代码如下:
setlocal EnableDelayedExpansion rem.> "C:output.txt" for /F "delims=" %%L in ('findstr /L "T" "C:test filestest.txt"') do ( set "liNE=%%L" & set "liNE=!liNE:*ResponseCode=!" & echo !liNE:~39,8%! )>> "C:output.txt" endlocal set sum=0 cd C:test files for /F "tokens=* delims=0" %%A in (output.txt) do set /a sum=sum+%%A echo The total Sales for today was %sum% > output2.txt output2.txt pause
我真的不知道该从哪里出发。 任何帮助,将不胜感激。
在批处理脚本中运行grep.exe(针对windows编译的Unix版本)时出现错误的原因是什么?
如何从文件打开命令提示符
什么是使用git ls-files复制修改文件的windows命令?
在windowsbatch file中,如何分割围绕关键字的标准input并将一半传递给另一个程序?
cmd.exe | 如何按特定格式计数文件?
编辑
原始文件如下所示:
“59”,003005213,23,10,0017,07,59,0000,03,03005213,04,00000000,00000000, “R”, 00000000“59”,002009205,08,00,0001,02,02009205,0.20001,00004300,00005000,00000700,“R” ,00000000“61”,0000000001879,00000010,1,00000430,01,0,“T”,002009205,0“59”,002009206,02 ,02009206,020001,00001200,000000,0000000,00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 “T”,002009206,0“59”,003005214,03005214,00006500,00000000 00000000“R”00000000“61”0000000001428,00000005,00001300,0“T”003005214,0“59”002009207,04 ,0002,02009207,0.20002,00003600,00001400,“R”,00000000“61” ,0000000000285,00000001,00002800,0,“T”,002009207,0“61”,0000000000430,00000002,00000400,00000800,0,“T”,002009207, 0“59”,003005215,03005215,00000000,“R” ,00000000“59”,003005216,09,03005216,“R “,00000000”59“,002009208,02009208,00007000,00010000,00003000,” R“,00000000”61“,0000000000337,0,”T“,002009208,0”59“,003005217,0000 ,03,03005217,“R”,00000000“61”,0000000001428,01, 0, “T”,003005217,0
每一行都以61或59开头。
然后filter后:
00004300 00001200 00006500 00002800 00000800 00007000 00006500 00002900 00000400 00003250 00000520 00002990 00003250 00001300 00005040 00000470 00000410 00002600 00017000 00002800 00001575 00006500 00002430 00001615 00002150 00000350 00001300 00001435 00006500 00002600 00003250 00001860 00003250 00002985 00000430 00001200 00000860 00000515 00002350 00001300 00001300 00001005 00000865 00000430 00002200 00006500 00002490 00001985 00001300 00013000 00001300 00006500 00001300 00006500 00006500 00001300 00003250 00003925 00001160 00002800 00006500 00002200 00001300 00000430 00003250 00000615 00013000 00005490 00002600 00002510 00001300 00008445 00003250 00004595 00013000 00001000 00001005 00001300 00006500 00001300 00001300 00003255 00000670 00002600 00004400 00002480 00001490 00001950 00002895 00003120 00003525 00003250 00005660 00013000 00001470 00006500 00010810 00003250 00003870 00000550 00000400 00001460 00003250 00001300 00000430 00003250 00000430 00007000 00007165 00026000 00003250 0 0002445 00006500 00003890 00003390 00003250 00002800 00002395 00005555 00002970 00002700 00003445 00003150 00001520 00000930 00010205 00002945 00003250 00001120 00006500 00001215 00006500 00001980 00001495 00002040 00000400 00003250 00000220 00006500 00003250 00006140 00002600 00009750 00000525 00002405 00001920 00000995 00000430 00000430 00006500 00001965 00006500 00001070 00000810 00000430 00017000 00000485 00002010 00006500 00001105 00003480 00003250 00003250 00010025 00000510 00003250 00007000 00003250 00002320 00006500 00002600 00000650 00010345 00005340 00002995 00001240 00003250 00001005 00006500 00001015 00003250 00005065 00000430 00000580 00000450 00000860 00004550 00000430 00001300 00010560 00000880 00000465 00006500 00000840 00003250 00006060 00002600 00010625 00003250 00000430 00000920 00000930 00002600 00005245 00001300
然后我将它们加在一起,放下前导零来得到我的最终总数。
包含二进制可执行文件
如何在使用netcat时根据请求有条件地做出响应
通过批处理脚本更新多个heroku应用程序
如何通过使用“findstr”来匹配IP地址? 或者在windows中批处理的任何其他方法
BAT / CMD文件使用disKPART删除驱动器号
echo The total Sales for today was %sum:~0,-2%.%sum:~-2% > output2.txt
也就是输出sum ,除了最后2个字符和一个点,然后是最后2个字符。
总结以上是内存溢出为你收集整理的在bat文件中编辑一个string全部内容,希望文章能够帮你解决在bat文件中编辑一个string所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)