Getting the file extenseion

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
eddyq
Posts: 2
Joined: 17 Feb 2013 09:48

Getting the file extenseion

#1 Post by eddyq » 17 Feb 2013 09:53

In at .BAT file, to get a file extension I am doing this:
for %%1 in (file_name.ext) do set ItemExt=%~x1

But that keeps the dot so the extension comes out ".ext". I want it to be just "ext".

Is there a way?

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Getting the file extenseion

#2 Post by Squashman » 17 Feb 2013 11:18

set itemext=%itemext:~1%

eddyq
Posts: 2
Joined: 17 Feb 2013 09:48

Re: Getting the file extenseion

#3 Post by eddyq » 17 Feb 2013 12:10

It worked!

Thanks

Post Reply