Getting a file extension in Godot 4

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ralshi02

The getextension() function doesn’t seem to exist anymore to get a file extension and I can’t seem to find any other way to check a file type.

if file_name.getextension()=="wav":
:bust_in_silhouette: Reply From: jgodfrey

The String class still has a get_extension() method in Godot 4. See the docs here:

Here’s a usage example:

var st = "c:/my/file/name.txt"

prints → txt

jgodfrey | 2023-03-14 17:33