批量文件 - 如何获取文件名中的特定单词/字母? [英] BATCH FILE - How to get a specific word/letters in a filename?

查看:112
本文介绍了批量文件 - 如何获取文件名中的特定单词/字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取文件名中的字母/单词?



例如: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.


这篇关于批量文件 - 如何获取文件名中的特定单词/字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆