(view source code of listverbs.bat as plain text)
@ECHO OFF
IF "%~1"=="" GOTO Syntax
IF NOT "%~2"=="" GOTO Syntax
ECHO.%* | FIND.EXE "?" >NUL && GOTO Syntax
ECHO.%~1| FINDSTR.EXE /R /X /C:"\.[a-z0-9][a-z0-9]*" >NUL || GOTO Syntax
SETLOCAL ENABLEDELAYEDEXPANSION
SET ColumnWidth=0
SET RC=0
FOR /F "tokens=2 delims==" %%A IN ('ASSOC "%~x1"') DO (
ECHO Extension = %1
ECHO File Type = %%A
ECHO Verbs:
FOR /F "tokens=1-4* delims=\" %%C IN ('REG Query HKCR\%%~A\shell') DO (
SET /A RC += 1
CALL :GetMaxStringLength ColumnWidth "%%~F"
)
FOR /F "tokens=1-4* delims=\" %%C IN ('REG Query HKCR\%%~A\shell') DO (
FOR /F "tokens=2*" %%G IN ('REG Query "%%~C\%%~D\%%~E\%%~F\command" ^| FIND /V "HKEY_"') DO (
REM Append 40 spaces after verb name
SET Column=%%F
REM Chop at maximum column width
FOR %%I IN (!ColumnWidth!) DO SET Column=!Column:~0,%%I!
ECHO !Column! %%H
)
)
)
ENDLOCAL & EXIT /B %RC%
:GetMaxStringLength
:: Usage : GetMaxStringLength OutVariableName StringToBeMeasured
:: Note : OutVariable may already have an initial value
SET StrTest=%~2
SET /A %1 += 0
FOR /L %%A IN (!%1!,1,40) DO (
IF NOT "!StrTest:~%%A!"=="" (
SET /A %1 = %%A + 1
)
)
GOTO:EOF
:Syntax
ECHO.
ECHO ListVerbs.bat, Version 1.00 for Windows
ECHO List all verbs for the specified file extension
ECHO.
ECHO Usage: ListVerbs.bat fileextension
ECHO.
ECHO Where: fileextension is the file extension to list the
ECHO available verbs for e.g. ".odt"
ECHO.
ECHO Note: Return code ("errorlevel") equals the number of verbs
ECHO found, or -1 in case of (command line) errors.
ECHO.
ECHO Written by Rob van der Woude
ECHO https://www.robvanderwoude.com
EXIT /B -1
page last modified: 2024-04-16; loaded in 0.0070 seconds