# How do I know the path to the file in the Blender Game Engine?

In BGE, in an initialization script, I have these instructions:

var=bge.logic.expandPath("//")
print("====== path=",var,"=======")


and now the variable "var" is set to the path of the Blender file.

Ok, but when I export the game (Save As Game Engine Runtime) and move the saved file to another path or another PC, the "var" variable does not change, i.e. it remains the one it was before moving the file.

• Thank you for your answer. What you suggest is right, but I want to launch the game from the terminal. I would like to run it through a script:  #!/bin/bash exec "/game_path/mygame"  And even if I do  cd "$(dirname "$0") exec "/game_path/mygame"  (dirname "\$0") sets the current directory to the script path the instruction  var=bge.logic.expandPath("//")  in the game script sets "var" to the path to the Blender file at the time of export. Translated with www.DeepL.com/Translator – Ave Mar 22 '18 at 11:04