How to find the file path of currently the running godot application

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

Quick and kind of stupid question but I’m working on a program and I’m lazy so it’s a godot app that relies on a python script to run and few files to communicate between the two. When I release this program, it will be a folder that the user can download that contains all the separate apps and files, and it’s a computer program so the user can relocate the main folder wherever they want. This means I don’t know where the path for the project is, and that means the Godot application can’t communicate with the other scripts and files.

So, how do I find the exact file path of the app when the user runs it? I’m guessing there is a method for this somewhere but I looked it up and scanned the docs and didn’t find anything. Thanks!

Not sure, I understand you correctly, but maybe just use relative file paths instead of absolute file paths.

So “this/is/relative” instead of “C:/this/is/absolute” or “/this/is/absolute” on Unix-style file systems.

kbal | 2022-08-04 07:46

:bust_in_silhouette: Reply From: aengus126

answering my own question: as the other user who commented mentioned, you can use relative paths to get what you want when in editor and OS.get_executable_path() to get the path of the currently running executable. In debug mode, the currently running executable is located where Godot is installed so that’s not what you want but when you export it and run the exe then it gives the path of the exe.