标题: [文本处理] 批处理如何输出百分号% [打印本页]
作者: 断桥 时间: 2019-3-1 14:24 标题: 批处理如何输出百分号%
本帖最后由 pcl_test 于 2019-3-1 16:58 编辑
求大神帮忙看下输出的文件不缺少%号
要求输出后的代码与“输出正确的批处理代码”一致
但是我写的批处理输出来一直缺少%号,请大神帮忙看下问题怎么解决,谢谢。
生产工具批处理代码:- set file=config.ini
- set bat=Automatic.cmd
- @echo call >>config.ini
- @echo @echo off >>Automatic.cmd
- @echo setlocal enabledelayedexpansion >>Automatic.cmd
- @echo cd %~dp0 >>Automatic.cmd
- @echo for /f "delims=" %%i in (config.txt) do ( >>Automatic.cmd
- @echo set "str=%%i" >>Automatic.cmd
- @echo ) >>Automatic.cmd
- @echo,%str%
- @echo .\setup.exe /config=%str% >>Automatic.cmd
- @echo pause >>Automatic.cmd
复制代码
输出正确的批处理代码:- @echo off
- setlocal enabledelayedexpansion
- cd D:\SS\
- for /f "delims=" %%i in (config.txt) do (
- set "str=%%i"
- )
- .\setup.exe /config=%str%
- pause
复制代码
输出错误的批处理代码:- @echo off
- setlocal enabledelayedexpansion
- cd D:\SS\
- for /f "delims=" %i in (config.txt) do (
- set "str=%i"
- )
- .\setup.exe /config=
- pause
复制代码
作者: yhcfsr 时间: 2019-3-1 16:36
- set file=config.ini
- set bat=Automatic.cmd
- @echo call >>config.ini
- @echo @echo off >>Automatic.cmd
- @echo setlocal enabledelayedexpansion >>Automatic.cmd
- @echo cd %~dp0 >>Automatic.cmd
- @echo for /f "delims=" %%%%i in (config.txt) do ( >>Automatic.cmd
- @echo set "str=%%%%i" >>Automatic.cmd
- @echo ) >>Automatic.cmd
- @echo,%str%
- @echo .\setup.exe /config=%%str%% >>Automatic.cmd
- @echo pause >>Automatic.cmd
复制代码
作者: Batcher 时间: 2019-3-1 21:30
可以参考另外一种思路:
https://mp.weixin.qq.com/s/McvY4CiR-SYGaCha7lmjIw
作者: 断桥 时间: 2019-3-2 11:51
yhcfsr 发表于 2019-3-1 16:36
多谢“yhcfsr”大神,问题已经解决。
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |