我有一个包含以下文本的文本文件。
“模块”
{ "ModuleSignature" = "8:MergeModule.6F1248514B3047E99E4EE8A129CB8605" "Version" = "8:1.0.0.0" "Title" = "8:uoipmsm" "Subject" = "8:" "Author" = "8:Microsoft" "Keywords" = "8:" "Comments" = "8:" "SearchPath" = "8:" "UseSystemSearchPath" = "11:TRUE" "TargetPlatform" = "3:1" "PreBuildEvent" = "8:" "PostBuildEvent" = "8:" "RunPostBuildEvent" = "3:0" }
在上面; 我想更改从工具触发构建时将提供的版本号。
我想在批处理文件中传递一个参数$Version,它必须从我使用的工具中获取版本号,并在该文本文件中更新相同的版本号。
例如:在上面的文本中,我想将其编码为 "Version" = "8:$Version" 因此,当我在触发构建时提供版本号时,它必须在此文本文件中更新相同的版本号。
您能否指导我如何编辑特定行。我是 Windows 批处理脚本的新手。
我必须再添加一点......在文本文件中我必须修改第 399 行中的版本。因此批处理文件必须跳转到该文本文件中的第 399 行并进行修改。请帮我解决同样的问题...
我已将上述脚本保存在文本键盘中,并与 ver.bat 保存相同;并且在同一个文件夹中我保存了 Intext 文件。当我提到要替换的行号时,它正在删除“=”符号之后的内容,从第 1 行到第 399 行。
在运行批处理文件之前:
"ModuleSignature" = "8:MergeModule.6F1248514B3047E99E4EE8A129CB8605"
"Version" = "8:1.0.0.0"
"Title" = "8:uoipmsm"
"Subject" = "8:"
"Author" = "8:Microsoft"
"Keywords" = "8:"
"Comments" = "8:"
"SearchPath" = "8:"
"UseSystemSearchPath" = "11:TRUE"
"TargetPlatform" = "3:1"
"PreBuildEvent" = "8:"
"PostBuildEvent" = "8:"
"RunPostBuildEvent" = "3:0"
如果我运行批处理文件,我提到行号为 10 和 tat 之后;我得到以下输出;
"ModuleSignature" =
"Version" = ""
"Title" =
"Subject" =
"Author" =
"Keywords" =
"Comments" =
"SearchPath" =
"UseSystemSearchPath" =
"TargetPlatform" =
"PreBuildEvent" =
"PostBuildEvent" =
"RunPostBuildEvent" =
任何想法??