# Dynamic file name in schema

**URL:** <https://community.shotgridsoftware.com/t/dynamic-file-name-in-schema/4457>\
**Category:** Pipeline Integrations\
**Tags:** folders, schema\
**Created:** [January 3, 2020, 2:39pm UTC](https://community.shotgridsoftware.com/t/dynamic-file-name-in-schema/4457 "2020-01-03T14:39:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maelfr](https://avatars.discourse-cdn.com/v4/letter/m/13edae/32.png) [@maelfr](https://community.shotgridsoftware.com/u/maelfr)\
**Post date:** [January 3, 2020, 2:39pm UTC](https://community.shotgridsoftware.com/t/dynamic-file-name-in-schema/4457/1 "2020-01-03T14:39:49Z")

</div>

hello,  
is it possible to have files in the core/schema with dynamic file names the same way dynamic folders work?

I would like to have some default files setup for certain tasks so we do not have to start from scratch in certain situations. I would like these files to behave as dynamic folders do and get the shot and/or task name when created.

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [January 3, 2020, 3:28pm UTC](https://community.shotgridsoftware.com/t/dynamic-file-name-in-schema/4457/2 "2020-01-03T15:28:39Z")

</div>

Hey Mael

Welcome to the forums, and good question!

Our folder creation process doesn’t support dynamic naming of files, unfortunately, in the same way that folders are handled. I’ll submit an idea on your behalf [here](https://www.shotgunsoftware.com/roadmap/).  
You could potentially implement dynamic naming of files through the [process\_folder\_creation.py](https://github.com/shotgunsoftware/tk-core/blob/v0.18.172/hooks/process_folder_creation.py) core hook.

It’s not very pretty but I tested something here which seems to work, but I can’t really vouch for its robustness.

I added a file to my schema with `{entity}` in the file name:  
 ![project_root](https://global.discourse-cdn.com/shotgunsoftware/original/2X/e/e6097c98979b178faa98812d5c340d4901832f1d.png)

Then I added the following [here](https://github.com/shotgunsoftware/tk-core/blob/v0.18.172/hooks/process_folder_creation.py#L107-L112).

```python
        current_entity = None
        try:

            # loop through our list of items
            for i in items:
                
                # get and store the current entity, so it can be used to name files that are children of the entity folder.
                entity = i.get("entity")
                if entity and entity["type"] in ["Asset", "Shot"]:
                    current_entity = i["entity"]

```

And the following [here](https://github.com/shotgunsoftware/tk-core/blob/v0.18.172/hooks/process_folder_creation.py#L167).

```python
                    # dynamically rename the file based on the entity name gathered from an earlier item
                    # in this item loop.
                    if current_entity and "{entity}" in target_path:
                        target_path = target_path.replace("{entity}", current_entity["name"])

```

Which resulted in:

 ![philscad](https://global.discourse-cdn.com/shotgunsoftware/original/2X/d/d8504d77705d58844217fd9c8938b4f8eb7f4c93.png)

The reason for this slightly strange approach is that the item doesn’t know the context, so the only way I could find the entity name was to store it as it looped over the items. Since it creates the folders in the order of root to leaf, you can gather the entity before it gets to create the file, assuming the file is in a child folder of a dynamic entity folder.

---

<div class="post-metadata">

**Author:** ![Ľubomír\_Timko](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/%C4%BEubom%C3%ADr_timko/32/2852_2.png) [@Ľubomír\_Timko](https://community.shotgridsoftware.com/u/%C4%BDubom%C3%ADr_Timko)\
**Post date:** [June 11, 2020, 3:01pm UTC](https://community.shotgridsoftware.com/t/dynamic-file-name-in-schema/4457/4 "2020-06-11T15:01:52Z")

</div>

Hello, any update for dynamic file naming when saving files in nuke/maya?

Thanks

---

<div class="post-metadata">

**Author:** ![philip.scadding](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/philip.scadding/32/30_2.png) [@philip.scadding](https://community.shotgridsoftware.com/u/philip.scadding)\
**Post date:** [June 15, 2020, 10:08am UTC](https://community.shotgridsoftware.com/t/dynamic-file-name-in-schema/4457/5 "2020-06-15T10:08:55Z")

</div>

No unfortunately not, our focus on the integrations side has been mostly on Python 3 support at the moment.
