|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
namajm兄在F11中的代码是测试错误的代码还是正确的代码?
我这里测试,没有通过,显示的是"ab",而不是我们想得到的"ab c",不知道咋回事。。
Brother namajm, is the code in F11 a test error code or a correct code?
I tested here and it didn't pass. It shows "ab" instead of the "ab c" we want. I don't know why.
|
|
2006-10-21 02:54 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
不好意思,我举的例子是想说明那段代码不能正确获取带空格路径中指定层次的文件夹名,当时没有注释清楚,现在已经注释好了。
I'm sorry, the example I gave was to show that the code couldn't correctly get the folder name of the specified level in the path with spaces. I didn't make it clear at that time, but now it's commented properly.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-10-21 06:15 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
14F的代码确实厉害,用到了比较生僻的shift,颇具技巧性,它可能是最具备通用性的了。
The code in 14F is really remarkable. It uses a relatively obscure shift, which is quite skillful. It might be the most general-purpose one.
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-10-21 06:17 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
呵呵。。。
我一直在思考这个问题:
为什么在11楼的代码不行,而在14楼的代码却可行呢?难道就是这个shift起的作用?也没有明白为什么要循环4次。
Hehe...
I've been thinking about this question all the time:
Why does the code on floor 11 not work, but the code on floor 14 does? Is it just the role of this shift? I still don't understand why we need to loop 4 times.
|
|
2006-10-21 07:03 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
多看看 <帮助与支持>吧.
不一样的搭配就有不一样的味,这也是脚本存在的原因之一:
@echo off
setlocal ENABLEDELAYEDEXPANSION
set str=c:\ab c\def\gh .exe\
set num=1
for /l %%i in (1,1,%num%) do set "str=!str:*\=!"
echo %str:\= && 2>nul cd %
pause
把最后的cd换成echo就可以逐级显示.
几种方法使用的场合不同,至于孰好孰坏,那就是见仁见智了.
Take a look at <Help and Support> more. Different combinations have different flavors, which is also one of the reasons for the existence of scripts:
@echo off
setlocal ENABLEDELAYEDEXPANSION
set str=c:\ab c\def\gh .exe\
set num=1
for /l %%i in (1,1,%num%) do set "str=!str:*\=!"
echo %str:\= && 2>nul cd %
pause
Changing the final cd to echo allows displaying level by level. The several methods are used in different situations, and as for which is better or worse, that is a matter of personal opinion.
|
|
2006-10-21 07:35 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
发现 echo %str:\= && 2>nul cd % 一句中,把cd换成任意的命令都能正确执行,对这一句去掉最后几个\分隔的内容的写法百思不得其解,还请3742668解说一二。
另外,echo %str:\= && 2>nul cd %在提取其中的文件夹名的时候,最后一位是空格,在提取文件名的时候没有这个问题,换成 echo %str:\=&& 2>nul cd % 就可以了(注意:两条语句&&前一个有空格,一个没有空格)。
I found the sentence "echo %str:\= && 2>nul cd %". I can't figure out how to write to remove the last few content separated by \. I hope 3742668 can explain it.
In addition, when extracting the folder name from "echo %str:\= && 2>nul cd %", the last character is a space. There is no this problem when extracting the file name. It can be changed to "echo %str:\=&& 2>nul cd %" (note: there is a space before && in the two statements and no space in one).
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-10-21 08:39 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
Originally posted by 3742668 at 2006-10-21 07:35:
多看看 <帮助与支持>吧.
不一样的搭配就有不一样的味,这也是脚本存在的原因之一:
几种方法使用的场合不同,至于孰好孰坏,那就是见仁见智了.
同意, 解决问题的方法多种多样, 就看你怎么用了.
Originally posted by 3742668 at 2006-10-21 07:35:
Take a look at the <Help and Support> more.
Different combinations have different flavors, which is also one of the reasons why scripts exist:
Several methods are used in different situations, and as for which is better or worse, that is a matter of personal opinion.
Agree, there are various ways to solve problems, just see how you use them.
|
|
2006-10-21 08:43 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
Originally posted by namejm at 2006-10-21 08:39:
发现 echo %str:\= && 2>nul cd % 一句中,把cd换成任意的命令都能正确执行,对这一句去掉最后几个\分隔的内容的写法百思不得其解,还请37426 ...
记得在那篇讨论加密解密的贴子里就有使用到过类似的方法.
原理很简单,例如:
set "command=set i=3"
echo i的值:%i% & pause
%command%
echo i的值:%i% & pause
参考: 非编译型批处理加密方案与代码之11F方案。
另外其实最后一种方法还存在一点小问题,获得最后的文件名时可能显示出一行"ECHO 处于打开状态"之类的提示,为了节省代码量,没对它进行处理.
Originally posted by namejm at 2006-10-21 08:39:
I found that in the sentence "echo %str:\= && 2>nul cd %", replacing "cd" with any command can execute correctly. I can't figure out the writing method of removing the last few \-separated contents. I still need to ask 37426...
I remember that a similar method was used in that post discussing encryption and decryption.
The principle is very simple, for example:
set "command=set i=3"
echo i的值:%i% & pause
%command%
echo i的值:%i% & pause
Reference: Non-compiled Batch Processing Encryption Scheme and Code of 11F scheme.
In addition, in fact, there is still a small problem with the last method. When getting the final file name, a prompt like "ECHO is on" might be displayed. To save code quantity, it was not processed.
|
|
2006-10-21 09:00 |
|
|
uemuem
初级用户
 
积分 153
发帖 68
注册 2006-10-12 来自 上海
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
Originally posted by 3742668 at 2006-10-21 09:00:
记得在那篇讨论加密解密的贴子里就有使用到过类似的方法.
原理很简单,例如:
set "command=set i=3"
echo i的值:%i% & pause
%command%
ech ...
经测试,确实会出现:“ECHO处于打开/关闭状态的提示”,不知道怎么样解决这个问题,经常会碰到这个问题。。。
Originally posted by 3742668 at 2006-10-21 09:00:
I remember that a similar method was used in that post discussing encryption and decryption.
The principle is very simple, for example:
set "command=set i=3"
echo i的值:%i% & pause
%command%
ech ...
After testing, it does appear: "The prompt that ECHO is on/off", I don't know how to solve this problem, I often encounter this problem...
|

个人主页-找餐厅:http://www.canting.cc |
|
2006-10-24 03:32 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
请问是在什么情况下出现“ECHO处于打开/关闭状态“的提示的?请把测试的路径发出来看一下。估计把 echo %str:\= && 2>nul cd % 修改成 echo. %str:\=&& 2>nul cd % 就可以了(注意:echo后有一个点号)。
May I ask under what circumstances the prompt "ECHO is in the on/off state" appears? Please send out the test path for me to take a look. It is estimated that changing echo %str:\= && 2>nul cd % to echo. %str:\=&& 2>nul cd % will work (note that there is a dot after echo).
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-10-24 06:39 |
|
|
cl87388881
初级用户
 
积分 46
发帖 22
注册 2006-10-24
状态 离线
|
|
2006-10-24 21:58 |
|