『第 16 楼』:
使用 LLM 解释/回答一下
看来 %%~fi 扩展路径的时候是有条件限制的,12F的代码确实能准确取到真实的绝对路径,不过这个绝对路径是 dir 出来的,而不是通过 %%~fi 扩展出来的,把 set Name=%%~fa 换成 set Name=%%a,效果一样。
不过,12F的代码是有缺陷的:当在不同文件夹下存在同名文件的时候,再次用 dir 来查询,则只能取到其中一个目录下的同名文件,而不能取到全部;不理解 find /v "序列 用意何在,假设某个文件名或者路径名中含有 序列 二字,那岂不是过滤掉了吗?
另外,15F的举例中,用^|findstr ".mmf“ 的格式,会查找到文件名中含有 mmf 的所有文件,而不仅仅是只查到后缀名为 .mmf 的文件,这是因为 findstr 支持正则表达式,而点号在正则表达式中是匹配任意字符的。
综合各种方案的优缺点,我觉得只有通过产生临时文件的方法,才有可能完成楼主的要求。
Last edited by namejm on 2006-11-8 at 08:21 PM ]
It seems that there are conditional restrictions when expanding the path with %%~fi. The code of 12F can indeed accurately get the real absolute path, but this absolute path is obtained by dir, not by expanding with %%~fi. Changing set Name=%%~fa to set Name=%%a has the same effect.
However, the code of 12F has a flaw: when there are files with the same name in different folders, when dir is used again to query, it can only get the file with the same name in one of the directories, not all; I don't understand the purpose of find /v "sequence". Suppose a file name or path name contains the word "sequence", then it will be filtered out?
In addition, in the example of 15F, the format of ^|findstr ".mmf" will find all files whose file names contain mmf, not just files whose suffix is .mmf, because findstr supports regular expressions, and the dot matches any character in the regular expression.
Considering the advantages and disadvantages of various schemes, I think only the method of generating temporary files may be able to meet the requirements of the owner.
Last edited by namejm on 2006-11-8 at 08:21 PM ]
|