batch-file - 如何使用 Effective("flyer", 100%) 搜索行;在文件中并获取分配给变量的数字?
问题描述
这个问题类似于我之前的问题How to search for line with ConstructionTime(10); 在文件中并获取分配给变量的数字?Mofi用以下代码解决了这个问题:
@echo off
set "ConstrutionTime="
for /F "tokens=2 delims=()" %%I in ('%SystemRoot%\System32\find.exe /I "constructiontime" file.cfg') do set "ConstrutionTime=%%I"
if defined ConstrutionTime echo The construction time is: %ConstrutionTime%
我可以10
使用.ConstructionTime=(10);
file.cfg
但是呢Effective("flyer", 100%);
?
如何从中获取100
并将其分配给环境变量?
解决方案
获得正确的标记和分隔符(不要关心,它会通过解析%
丢失)
@echo off
set "string=Effective("flyer", 100%);"
for /f "tokens=2 delims=) " %%a in ("%string%") do set "number=%%a"
set number
推荐阅读
- c# - 有没有一种简单的方法来表示子组件中发生的数据更改?
- python - 如何在不使用和拆分测试集的情况下将我的数据集拆分为训练和验证?
- python - 在 Dataframes (Python) 中使用“For”和“If”的问题
- python - Python 3.6.1 找不到包和模块 [import]
- python - 将元组中的日期时间值转换为 YMD
- excel - 将此 vba 输出到单元格中
- objective-c - 将 Interface Builder 设置转换为 Objective-C
- r - 是否有一个 R 函数可以通过每天重复每月值来从每月数据到每日数据?
- node.js - 使用 mongodb 在用户的所有帖子中获取用户的点赞数
- java - 播放音乐时媒体播放器按钮崩溃