标题: 请教:批处理变量中带=的处理方法。(dos下,非CMD)
[打印本页]
作者: lianjiang2004
时间: 2007-8-7 13:24
标题: 请教:批处理变量中带=的处理方法。(dos下,非CMD)
请教:批处理变量中带=的处理方法。(dos下,非CMD)
比如有一批处理test.bat,其中有 %1 %2 %3等。在输入的变量中有形如 -cc=123的形式。
假如按 test aa bb -cc=123的格式运行的话,结果是: %1是aa, %2是bb, %3是-cc,%4是123,有什么办法能比较简便地处理后得到%3为-cc=123?
另,-cc=123不一定就是%3,也可以是%2,如运行test aa -cc=123 bb。
谢谢。
作者: wangbadan
时间: 2007-8-7 17:48
标题: 我也有同样的问题!顶!
我也有同样的问题!顶!
作者: lianjiang2004
时间: 2007-8-7 19:23
没办法,只好用穷举的笨办法处理了。
此批处理用于ghost自动备份。
作者: tyh
时间: 2007-8-8 10:54
我是这么搞的,当然,也不好。
for /f "tokens=1-3 delims=; " %%i in ("%qq%") do (
set pp=%%j
if "!pp:~-2!"=="==" (set pp===) else (
if "!pp:~-1!"=="=" set pp==
))
作者: knoppix7
时间: 2007-8-10 13:32
MS-DOS里有for/f吗?
Runs a specified command for each file in a set of files.
FOR %variable IN (set) DO command [command-parameters]
%variable Specifies a replaceable parameter.
(set) Specifies a set of one or more files. Wildcards may be used.
command Specifies the command to carry out for each file.
command-parameters
Specifies parameters or switches for the specified command.
To use the FOR command in a batch program, specify %%variable instead of
%variable.
作者: lianjiang2004
时间: 2007-8-10 13:38
Quote: |
Originally posted by tyh at 2007-8-8 10:54:
我是这么搞的,当然,也不好。
for /f "tokens=1-3 delims=; " %%i in ("%qq%") do (
set pp=%%j
if "!pp:~-2!"=="==" (set pp===) else (
if & ... |
|
没看清标题吧?呵呵。
dos下,非CMD
作者: ansipeter
时间: 2007-8-10 14:17
楼主可以用这样的形式试试
test aa bb “-cc=123”
因为没有纯DOS的测试环境,所以没有测试结果