@echo off & setlocal enableextensions
::
if "%~1"=="" (
echo Usage: %~0 Extension
goto :EOF
)
set ext_=%~1
::
for /f "tokens=2 delims==" %%a in (
'assoc^|find /i "%ext_%"') do set assoc_=%%a
echo %ext_% %assoc_%
if defined assoc_ (
reg query HKLM\SOFTWARE\Classes\%assoc_%|find "REG_SZ"
) else (
echo No association)
endlocal & goto :EOF
The output might be e.g.
C:\_D\TEST>cmdfaq .html
.html FirefoxHTML
AlwaysShowExt REG_SZ
<NO NAME> REG_SZ HTML Document
C:\_D\TEST>cmdfaq .dir
.dir
No association
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip
The addition gives the programs associated with the extension.
Have you looked at the Ftype command? I've got a script at work that
has more substance than the one-liner below, but it covers the
concept.
for /f "tokens=1* delims==" %%a in ('assoc %1') do ftype %%b
Thanks,
Clay Calvert
CCal...@Zanguru.com
Replace "Z" with "L"
That is very nice. Thank you Clay.
Let's test a bit with yours included
@echo off & setlocal enableextensions
::
if "%~1"=="" (
echo Usage: %~0 Extension
goto :EOF
)
set ext_=%~1
::
for /f "tokens=2 delims==" %%a in (
'assoc^|find /i "%ext_%"') do set assoc_=%%a
echo Timo:
echo %ext_% %assoc_%
::
echo Clay:
for /f "tokens=1* delims==" %%a in ('assoc %1') do ftype %%b
::
endlocal & goto :EOF
Example 1 (ok)
C:\_D\BAS>cmdfaq .html
Timo:
.html FirefoxHTML
Clay:
FirefoxHTML=C:\PROGRA~1\MOZILL~1\FIREFOX.EXE -url "%1"
Example 2 (bafflement)
C:\_D\BAS>cmdfaq .lst
Timo:
.lst ft000016 [which can be used to get further information on .lst]
Clay:
File type 'ft000016' not found or no open command associated with it.
But I have .lst associated. From folder options, edit file type:
LST list text file
The SemWare Editor Professional
"C:\Program Files\TSEPro\tse32.exe" "%1"
Some limitations would appear to be in place with FTYPE.
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html
(My apologies for the potential repeat. The server is acting up.)
That is very nice. Thank you Clay.
Let's test a bit with yours included
@echo off & setlocal enableextensions
::
if "%~1"=="" (
echo Usage: %~0 Extension
goto :EOF
)
set ext_=%~1
::
for /f "tokens=2 delims==" %%a in (
'assoc^|find /i "%ext_%"') do set assoc_=%%a
echo Timo:
echo %ext_% %assoc_%
::
echo Clay:
for /f "tokens=1* delims==" %%a in ('assoc %1') do ftype %%b
::
endlocal & goto :EOF
Example 1 (ok)
C:\_D\BAS>cmdfaq .html
Timo:
.html FirefoxHTML
Clay:
FirefoxHTML=C:\PROGRA~1\MOZILL~1\FIREFOX.EXE -url "%1"
Example 2 (bafflement)
C:\_D\BAS>cmdfaq .lst
Timo:
.lst ft000016 [which can be used to get further information on .lst]
Clay:
File type 'ft000016' not found or no open command associated with it.
But I have .lst associated. From folder options, edit file type:
LST list text file
The SemWare Editor Professional
"C:\Program Files\TSEPro\tse32.exe" "%1"
Some limitations would appear to be in place with FTYPE.
All the best, Timo
> > for /f "tokens=1* delims==" %%a in ('assoc %1') do ftype %%b
> Let's test a bit with yours included
(SNIP)
> Example 2 (bafflement)
> C:\_D\BAS>cmdfaq .lst
> Timo:
> .lst ft000016 [which can be used to get further information on .lst]
> Clay:
> File type 'ft000016' not found or no open command associated with it.
>
> But I have .lst associated. From folder options, edit file type:
> LST list text file
> The SemWare Editor Professional
> "C:\Program Files\TSEPro\tse32.exe" "%1"
>
> Some limitations would appear to be in place with FTYPE.
Got it now. The "Action" in File Types must exclicitly be "open".
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
RazTK, I prefer the code formatted for easier understanding!
I have added the missing carets to your STDERR redirects
::-----START-----
01;@ECHO OFF&SETLOCAL ENABLEEXTENSIONS
02;FOR %%? IN (%*) DO CALL :CHECK %%?
03;ENDLOCAL&GOTO :EOF
04;:CHECK
05;ECHO/
06;FOR /F "DELIMS=." %%A IN ("%~1") DO (
07; FOR /F "TOKENS=2 DELIMS==" %%B IN ('ASSOC .%%A ^2^>NUL') DO (
08; FOR /F "TOKENS=2 DELIMS==" %%C IN ('FTYPE %%B ^2^>NUL') DO (ECHO/%%A : %%B)&(ECHO/%%B : %%C)
09; )||(ECHO/%%A : %%B)
10; )||(ECHO/'FILE EXTENSION %~1' NOT FOUND.)
11;GOTO :EOF
::------END------
And prettied a little
Note: Line numbers, 'nn;', included to prevent line wrap, should be removed