So the problem is that I will get filename such as:
"a.b.c.d.e.f.g"
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 for your help!
So the problem is that I will get filename such as:
"a.b.c.d.e.f.g"
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 for your help!
@ECHO OFF
SETLOCAL
SET "fname=a.b.c.d.e.f.g"
FOR %%a IN (%fname%) DO FOR %%b IN (%%~na) DO ECHO %%~xb%%~xa
try this:
@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%
€: works for all delimiters, not only .
.
You could use the parameter modifier x
in %~xI` to access only the extension and then use it twice.
@echo off
set "fname=a.b.c.d.e.f.g"
for /F "delims=" %%A in ("%fname%") DO (
set "ext2=%%~xA"
for /F "delims=" %%A in ("%%~nA") DO set "ext1=%%~xA"
)
echo %ext1%%ext2%