How to remove extension from file path?

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

I guess it could be done by using substr().

:bust_in_silhouette: Reply From: Ertain

Have you looked into the trim_suffix() String function?

:bust_in_silhouette: Reply From: Dlean Jeans

Call String.get_basename() or get_base_dir():

var path = 'res://path/to/file.tres'
print(path.get_basename()) # res://path/to/file
print(path.get_base_dir()) # res://path/to

Click here to run the code above.