How to get .ext ftype into variable

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
hlhp
Posts: 2
Joined: 24 Sep 2019 00:28

How to get .ext ftype into variable

#1 Post by hlhp » 24 Sep 2019 00:34

I want to create a batch to change extensions icon without chaning the ftype.

I can find ftype by

Code: Select all

assoc .png
output is

Code: Select all

.gif=Honeyview.gif
How can I extract the Honeyview.gif to a variable, then I can use it change the registry.

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: How to get .ext ftype into variable

#2 Post by penpen » 24 Sep 2019 01:52

You may use a "for/f"-loop (untested):

Code: Select all

@echo off
setlocal enableExtensions disableDelayedExpansion
for /f "tokens=* delims==" %%a in ('assoc .png') do set "%%~a"

echo(.png=%.png%
goto :eof
penpen

hlhp
Posts: 2
Joined: 24 Sep 2019 00:28

Re: How to get .ext ftype into variable

#3 Post by hlhp » 24 Sep 2019 03:59

penpen wrote:
24 Sep 2019 01:52
thank you penpen, it works.
I modified a little bit

Code: Select all

@echo off
FOR /F "delims== tokens=2" %%G IN ('assoc .gif') DO set temp1=%%G
echo %temp1%
pause

Post Reply