Board logo

标题: [文本处理] 批处理如何根据文本里列出的一个数字的大小执行不同操作 [打印本页]

作者: zll855    时间: 2016-11-13 02:33     标题: 批处理如何根据文本里列出的一个数字的大小执行不同操作

本帖最后由 pcl_test 于 2016-11-13 15:52 编辑

5.txt 文本内容就是一个数字
判断文本中数字是否大于5如果文本内数字大于5则运行1.bat如果小于5则运行2.bat
作者: pcl_test    时间: 2016-11-13 15:52

先学学基础知识吧,另外等于5呢
方法一set /p 或 for+if
方法二findstr+&&、||
http://www.bathome.net/thread-2530-1-2.html
http://www.bathome.net/thread-14927-1-4.html
http://www.bathome.net/viewthread.php?tid=14682
http://www.bathome.net/thread-2189-1-1.html
http://bbs.bathome.net/thread-31727-1-1.html
http://www.bathome.net/thread-5814-1-1.html
http://www.bathome.net/thread-75-1-1.html
作者: zll855    时间: 2016-11-13 16:15

回复 2# pcl_test


    谢谢老哥 我已经写好了
作者: Batcher    时间: 2016-11-15 09:24

回复 3# zll855


    代码发出来看看吧
作者: zll855    时间: 2016-11-17 00:32

  1. for /f "tokens=1" %%i in (1.txt) do (
  2.     for /f "tokens=1" %%j in ("%%i") do if %%j GEQ 4 (goto A) else goto 2
  3. )
复制代码

作者: GNU    时间: 2016-11-17 09:09

回复 5# zll855


"tokens=1" 是多余的吧,默认就是取第一列。
另外,一个for循环就够了吧。
  1. for /f %%i in (1.txt) do (
  2.     if %%i GEQ 4 (goto A) else goto 2
  3. )
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2