Set= log.txt in batch

徘徊边缘 提交于 2019-12-24 04:01:03

问题


I have like a log.txt file which contains:

MyName

My batch:

@echo off
set name= [log.txt]

in the [log.txt] part, it should read 'MyName' from the log.txt file, to set it as 'name'.

How?


回答1:


You can also use

set /p name=<log.txt

which might be considered shorter and a little less ugly.




回答2:


In cmd.exe, there's only this ugly way:

@echo off
for /f "usebackq tokens=* delims=" %%i in ("log.txt") do (
    set name=%%i
)


来源:https://stackoverflow.com/questions/932552/set-log-txt-in-batch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!