批量文件 - 如何获取文件名中的特定单词/字母?
如何获取文件名中的字母/单词?
例如:2012P02B.xml - 我只想得到这些字母:P02B
请帮帮我。谢谢和问候!
How to get the letters/word in a filename?
For Example: 2012P02B.xml - i just want to get the letters: "P02B"
Please help me. Thanks and Regards!
get是什么意思?回声?写入文件?加载到变量?
要获得回声,请尝试以下方法:
What do you mean by "get"? ECHO? Write to a file? Load into a variable?
To get echo, try this:
DIR 2012*.XML /B > TEST.TXT
for /F "eol=. tokens=2 delims=2." %i in (test.txt) do @echo %i
第一行创建一个文本文件,其中包含所有匹配文件的名称。
第二行在文本文件上运行,每次找到''分隔符''时将其拆分为''标记''。
分隔符是2和点。
如果你的文件是2012p03b.xml,那么代币将是:2 01 2 p03b .xml。
第二个令牌(%i)将是p03b。
希望这能指向正确的方向,
巴勃罗。
The first line creates a text file with bare names of all matching files.
The second line runs on the text file, splitting it into ''tokens'' each time it finds a ''delimiter''.
The delimiters are 2 and dot.
If your file is 2012p03b.xml, the tokens would be: 2012p03b.xml.
The second token (%i) would be p03b.
Hope this points you in the right direction,
Pablo.