How to get disk or SourceControl path from an asset's game path (Blueprint or python)


I’ve got an asset path (‘/Game/…’) and I want to convert it to the SourceControl depot path (‘//…/Content/…’) or at least to the local path (on my local disk).
I’ve not found anything in Paths or SourceControl documentation.

I could do something like this :
game_asset_path.replace(‘/Game/’, unreal.Paths.project_content_dir())

but the file extension is different between the asset (‘my_asset_name.my_asset_name’) and the file (‘my_asset_name.uasset’) so I can’t deduce it from it.

Hello! You can try this

  • let path will be asset path
  • if path contains “.” then take part to the left of it (throw away dot itself also)
  • add proj prefix to path

That should be it…

Thanks for the reply, but if I want to perform operations on my local file, I need its full path, extension included.
Currently I assume it’s a .uasset and I’m doing what you suggest + adding ‘.uasset’ at the end of the full_path.
But if a user calls this function to query a level file path, then it’s not valid as level files extensions are ‘.umap’.

At the moment I dont find if there is common way to get .tail part from assets… Even in plugin copy code they use just a list of cases as strings… it seems that there is no common and easy way to get that… As for practical thing - you can just collect all existing .tails and create simple replcaer for them

You are looking for get_system_path function from SystemLibrary unreal.SystemLibrary — Unreal Python 4.27 (Experimental) documentation

1 Like