如何通过点分割的文件名并获得2最后部 [英] How to split a file name by dot and get the 2 last portion
本文介绍了如何通过点分割的文件名并获得2最后部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,问题是,我会得到的文件名如:
So the problem is that I will get filename such as:
"a.b.c.d.e.f.g"
和我需要获得2最后部分。在这种情况下,
and I need to get the 2 last portions. In this case,
"f.g"
和我不知道该字符串将多少个点有。
and I don't know how many dots the string will have.
THX您的帮助!
推荐答案
试试这个:
@echo off &SETLOCAL
SET "fname=a.b.c.d.e.f.g"
:loop
SET /a t+=1
SET "d="
FOR /f "tokens=%t% delims=." %%a IN ("%fname%") DO SET "d=%%a"
SET "f=%g%"&SET "g=%e%"&SET "e=%d%"
IF DEFINED d GOTO :loop
ECHO %f%.%g%
€:。适用于所有的分隔符,不仅
这篇关于如何通过点分割的文件名并获得2最后部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文