|
icyheart
中级用户
  
积分 216
发帖 81
注册 2007-8-6
状态 离线
|
『楼 主』:
[求助]谁能解释一下3742668版主这段代码的意思
使用 LLM 解释/回答一下
@echo off
echo 去掉引号:
call :replace 1.txt "
echo.
echo 替换字符:
call :replace 1.txt "谢谢您" "感谢您"
pause>nul
goto :eof
:replace
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=1* delims=" %%i in (%1) do set var=%%i & echo !var:%2=%3!
endlocal
goto :eof
这是3742668版主的代码有谁能解释一下呢?由其是这一句var:%2=%3
谢谢啦
@echo off
echo Remove quotes:
call :replace 1.txt "
echo.
echo Replace characters:
call :replace 1.txt "Thank you" "Thank you"
pause>nul
goto :eof
:replace
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=1* delims=" %%i in (%1) do set var=%%i & echo !var:%2=%3!
endlocal
goto :eof
This is the code of moderator 3742668. Can anyone explain it? Especially this line var:%2=%3
Thank you
|

Crossings must be my teacher
Modest progress can be |
|
2007-9-2 19:44 |
|
|
junchen2
高级用户
   
积分 537
发帖 219
注册 2007-8-4 来自 杭州--半山
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
如果1.txt中有 "感谢您 " 则替换为 "谢谢您" 不知道对不对
If there is "感谢您" in 1.txt, replace it with "谢谢您". Is that correct
|
|
2007-9-2 20:32 |
|
|
icyheart
中级用户
  
积分 216
发帖 81
注册 2007-8-6
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
不对,这是把 "感谢您 ""谢谢您"引号都去了
No translation needed as the content is already in English.
|

Crossings must be my teacher
Modest progress can be |
|
2007-9-2 20:49 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
看看帮助……
不明白的echo下看看它到底执行什么……
环境变量替换已如下增强:
%PATH:str1=str2%
会扩展 PATH 环境变量,用 "str2" 代替扩展结果中的每个 "str1"。
要有效地从扩展结果中删除所有的 "str1","str2" 可以是空的。
"str1" 可以以星号打头;在这种情况下,"str1" 会从扩展结果的
开始到 str1 剩余部分第一次出现的地方,都一直保持相配。
也可以为扩展名指定子字符串。
Take a look at the help...
If you don't understand, use echo to see what it actually executes...
The environment variable substitution has been enhanced as follows:
%PATH:str1=str2%
This will expand the PATH environment variable, replacing each "str1" in the expanded result with "str2".
To effectively remove all "str1" from the expanded result, "str2" can be empty.
"str1" can start with an asterisk; in this case, "str1" will match from the start of the expanded result to the first occurrence of the remaining part of str1.
Substrings can also be specified for file extensions.
|
|
2007-9-2 21:00 |
|
|
icyheart
中级用户
  
积分 216
发帖 81
注册 2007-8-6
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
嗯 你说的这个我知道,我是想知道在这段代码中,%2和%3各代表什么?
Um, I know what you're talking about. I just want to know what %2 and %3 represent in this code?
|

Crossings must be my teacher
Modest progress can be |
|
2007-9-2 21:34 |
|
|
junchen2
高级用户
   
积分 537
发帖 219
注册 2007-8-4 来自 杭州--半山
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
不明白你就建立个文本看看吗?不动脑筋就问
If you don't understand, just create a text and take a look? Don't ask without thinking
|
|
2007-9-3 07:16 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
还是看帮助……
如果命令扩展名被启用,CALL 会如下改变:
CALL 命令现在将卷标当作 CALL 的目标接受。语法是:
CALL:label arguments
一个新的批文件上下文由指定的参数所创建,控制在卷标被指定
后传递到语句。您必须通过达到批脚本文件末两次来 "exit" 两次。
第一次读到文件末时,控制会回到 CALL 语句的紧后面。第二次
会退出批脚本。键入 GOTO /?,参看 GOTO : EOF 扩展名的描述,
此描述允许您从一个批脚本返回。
另外,批脚本文本参数参照(%0、%1、等等)已如下改变:
批脚本里的 %* 指出所有的参数(如 %1 %2 %3 %4 %5 ...)
Still look at the help...
If command extensions are enabled, CALL will change as follows:
The CALL command now accepts labels as the target of CALL. The syntax is:
CALL:label arguments
A new batch file context is created with the specified arguments, and control is passed to the statement after the label is specified. You must "exit" twice by reaching the end of the batch script file twice. The first time you reach the end of the file, control returns to immediately after the CALL statement. The second time will exit the batch script. Type GOTO /? to see the description of the GOTO : EOF extension, which allows you to return from a batch script.
In addition, the batch script text parameter references (%0, %1, etc.) have changed as follows:
%* in the batch script indicates all arguments (such as %1 %2 %3 %4 %5 ...)
|
|
2007-9-3 09:38 |
|
|
不得不爱
超级版主
         我爱DOS
积分 5310
发帖 2044
注册 2005-9-26 来自 四川南充
状态 离线
|
|
2007-9-3 18:32 |
|
|
kgdetg1127
初级用户
 
积分 158
发帖 89
注册 2007-4-25
状态 离线
|
|
2007-10-23 14:21 |
|