This simple function will return the name extension of the given file or folder name. That is the part right of the rightmost found dot (if any) starting with the dot itself. To get the regular name part left of the name extension, you would use the function FileNamePart$() instead.
SYNTAX:
ext$ = FileExtension$ (file$)
INPUTS:
file$ (STRING)
- The file or folder name to get the extension from. Empty input is allowed here and will result into an empty extension.
- May also have a path, then only the file part (FilePart$()) is checked. However, a given path does not affect the function result.
RESULT:
ext$ (STRING)
- Depending on the given file or folder name:
- The found name extension inclusive the leading dot (regular operation).
- May be identical to FilePart$(file$), if it was a extension only (leading dot found).
- Empty, if input was empty or a name part only without an actual extension (no dot found).
- Should be logic, but just to clarify, the result will never contain a path, even if given in the input.
In either case (empty or not) the result is a valid extension to add to a file or folder name, as extensions are completely optional in any names.