Reputation: 34609
Say you have a filename that has more than 2 dots in it, such as .symbols.nupkg
. If you have a Batch script like this:
@echo off
setlocal EnableDelayedExpansion
echo %~x1
and you run it with the file in question, it will give you only the .nupkg
portion. Is there any way to get the full file extension from such a string?
Thanks for helping!
Upvotes: 1
Views: 570
Reputation: 34979
In Windows, the file extension is defined to be the portion from the last period.
Anyway, if you do want to extract the portion from the first period, you could use the following code:
set "FILE=%~nx1"
set "FILE=.%FILE:*.=%"
echo("%FILE%"
Upvotes: 1