Skip to main content

find_command

Locates an executable command within a provided or system-defined path, optionally accounting for platform-specific file extensions. It searches the filesystem for the command and returns the full path to the first match found, or None if no match exists.

def find_command(
cmd: string,
path: list = null,
pathext: list = null
) - > string

Locates the full executable path for a given command by searching through specified directories and checking for platform-specific file extensions.

Parameters

NameTypeDescription
cmdstringThe name or filename of the command to locate.
pathlist = nullA list of directory paths to search; defaults to the system PATH environment variable if not provided.
pathextlist = nullA list of executable file extensions to append during the search, such as .EXE or .BAT; defaults to the PATHEXT environment variable.

Returns

TypeDescription
stringThe absolute path to the executable if found, otherwise None.