# \[Python\] How to get the 'Data Source Folder' path?

**URL:** <https://forums.unrealengine.com/t/python-how-to-get-the-data-source-folder-path/481257>\
**Category:** Editor Scripting\
**Tags:** Python, data, source, unreal-engine, import, path, question\
**Created:** [April 2, 2021, 8:10am UTC](https://forums.unrealengine.com/t/python-how-to-get-the-data-source-folder-path/481257 "2021-04-02T08:10:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_077a2248](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_077a2248](https://forums.unrealengine.com/u/anonymous_user_077a2248)\
**Post date:** [April 2, 2021, 8:10am UTC](https://forums.unrealengine.com/t/python-how-to-get-the-data-source-folder-path/481257/1 "2021-04-02T08:10:56Z")

</div>

In order to get a given asset’s source path, I’m doing:

```
loaded_asset.get_editor_property('asset_import_data').get_first_filename()

```

This works fine, but I’d like to be able to get this path as a relative one, using the “Data Source Folder” as a root.

The “Data Source Folder” option is in “Editor Preferences \> General \> Miscellaneous \> Import \> Data Source Folder”.  
Is such an information accessible by script?

---

<div class="post-metadata">

**Author:** ![chadmv](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@chadmv](https://forums.unrealengine.com/u/chadmv)\
**Post date:** [September 16, 2021, 6:12pm UTC](https://forums.unrealengine.com/t/python-how-to-get-the-data-source-folder-path/481257/2 "2021-09-16T18:12:55Z")

</div>

You can do this

```
@unreal.uclass()
class EditorUtility(unreal.GlobalEditorUtilityBase):
    _instance = None

    @classmethod
    def get(cls):
        if not EditorUtility._instance:
            EditorUtility._instance = EditorUtility()
        return EditorUtility._instance

def get_data_source_folder():
    """Get the data source folder for the project.

    :raises: RuntimeError if the data source folder is not set
    :return:
    """
    settings = EditorUtility.get().get_editor_user_settings()
    data_source_folder = settings.get_editor_property("data_source_folder")
    if not data_source_folder or not data_source_folder.path:
        raise RuntimeError(
            "No Data Source Folder set. Set the Data Source Folder in "
            "Editor Preferences > Miscellaneous > Import > Data Source Folder"
        )
    return data_source_folder.path
```
