# Tk-multi-workfiles - 'saveas\_default\_name' setting

**URL:** <https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729>\
**Category:** Pipeline Integrations\
**Created:** [November 11, 2019, 2:56pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729 "2019-11-11T14:56:42Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Ricardo\_Musch](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/ricardo_musch/32/405_2.png) [@Ricardo\_Musch](https://community.shotgridsoftware.com/u/Ricardo_Musch)\
**Post date:** [June 11, 2024, 5:56pm UTC](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729/11 "2024-06-11T17:56:04Z")

</div>

Here it is.  
Add this to your core/hooks folder as `custom_name_resolver_from_ctx.py`

Then in workfiles2 you can add this to the `saveas_default_name` setting:

`saveas_default_name: hook:custom_name_resolver_from_ctx:task_name`

```python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 Mac Guff
# ----------------------------------------------------
#
# @author: Barbara Laigneau <barbara@dark-shot.com>
# @brief: Core Hook to get a name from a context

from sgtk import Hook
import os

class ProceduralNameFromContext(Hook):
    """
    """

    def execute(self, setting, bundle_obj, extra_params, **kwargs):
        """
        Get a name from the current context

        :param setting: The name of the setting for which we are evaluating
                        In our example above, it would be template_snapshot.

        :param bundle_obj: The app, engine or framework object that the setting
                           is associated with.

        :param extra_params: List of options passed from the setting. If the settings
                             string is "hook:hook_name:foo:bar", extra_params would
                             be ['foo', 'bar']

        returns: needs to return the name of the file, as a string
        """

        resolve_mode = extra_params[0]
        # the mode is basically the parameter passed from the config value - in this case task_name

        if resolve_mode == "task_name":
            ctx_task = bundle_obj.context.task
            return ctx_task["name"] if ctx_task else "scene"
        elif resolve_mode == "entity_name":
            ctx_entity = bundle_obj.context.entity
            return ctx_entity["name"] if ctx_entity else "scene"
        else:
            return "scene"

```

---

_[View the full topic](https://community.shotgridsoftware.com/t/tk-multi-workfiles-saveas-default-name-setting/3729)._
