如何使用常规Windows命令行增加文本文件中的值? [英] How do I increment a value in a textfile using the regular Windows command-line?
问题描述
我想为我的一个项目保留一个编译计数器。我认为一个快速和肮脏的方式,这样做是保持一个文本文件与一个纯数字,然后简单地调用一个小脚本,每次我编译增加。
我如何使用常规的Windows命令行执行此操作?
我真的不想安装一些额外的shell,
你可以尝试一下
@echo off
for / fdelims ==%% i in(counter。 txt)do set / A temp_counter = %% i + 1
echo%temp_counter%> counter.txt
假设count.bat和counter.txt位于同一目录中。 p>
I'd like to keep a "compile-counter" for one of my projects. I figured a quick and dirty way to do this would be to keep a text file with a plain number in it, and then simply call upon a small script to increment this each time I compile.
How would I go about doing this using the regular Windows command line?
I don't really feel like installing some extra shell to do this but if you have any other super simple suggestions that would accomplish just this, they're naturally appreciated as well.
You can try a plain old batchfile.
@echo off
for /f " delims==" %%i in (counter.txt) do set /A temp_counter= %%i+1
echo %temp_counter% > counter.txt
assuming the count.bat and counter.txt are located in the same directory.
这篇关于如何使用常规Windows命令行增加文本文件中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!