# Underscore in file name required

**URL:** <https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219>\
**Category:** Uncategorized\
**Created:** [December 4, 2023, 6:59am UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219 "2023-12-04T06:59:12Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikramj](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vikramj](https://community.shotgridsoftware.com/u/vikramj)\
**Post date:** [December 4, 2023, 6:59am UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/1 "2023-12-04T06:59:13Z")

</div>

![ksnip_20231204-115712](https://global.discourse-cdn.com/shotgunsoftware/original/2X/5/5f6b71a777bd6d97fea89a83ed43334e813f6cdd.png)

As see in image, shotgrid app prevents me from adding underscore to file name.  
I did search and find threads on shotgrid forum on this topic. It is not clear what specifically to do.to allow underscore in file names ( generally extending it for any dcc )

Can I add any random text to filename seperated by underscore. If this requires modification to  
tk-core ( as seen in some thread ), then I am afraid I do not see tk-core app in the config installation folder.

I did try to dissuade the team from not using underscore as it may break the pipeline somewhere. However I cannot push it on them so on a flip side after implementing if it breaks  
that will be most established way for us avoid using an underscore in file names

---

<div class="post-metadata">

**Author:** ![Patrick](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrick/32/4767_2.png) [@Patrick](https://community.shotgridsoftware.com/u/Patrick)\
**Post date:** [December 4, 2023, 6:28pm UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/2 "2023-12-04T18:28:48Z")

</div>

Underscores are used by SG to infer different fields from a filename.The “name” field here, isn’t the full filename, but the “name” field of the filename defined in the templates.yml of your pipeline configuration.  
Can you explain more about the reason you need underscores in the name? What information are you trying to include in the name that needs separated with underscores?

---

<div class="post-metadata">

**Author:** ![vikramj](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vikramj](https://community.shotgridsoftware.com/u/vikramj)\
**Post date:** [December 5, 2023, 6:21am UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/3 "2023-12-05T06:21:25Z")

</div>

Thank you for your response @Patrick . Usually the information can be for example

project\_seq001\_sh0010\_dept\_version.ma.  
project\_prop\_walkingChair\_model\_v001

no random text at all.

---

<div class="post-metadata">

**Author:** ![Patrick](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrick/32/4767_2.png) [@Patrick](https://community.shotgridsoftware.com/u/Patrick)\
**Post date:** [December 5, 2023, 9:31am UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/4 "2023-12-05T09:31:07Z")

</div>

Ok, are you using a custom pipeline config?  
If you take a look at templates.yml you can find the templates, in your case look for the maya ones, where the filenames are defined.

> <https://github.com/shotgunsoftware/tk-config-default2/blob/master/core/templates.yml>

You can see that the filenames are built from individual fields.

eg your examples would need templates configured as follows. You may need to customise the app or hooks logic to support some of these fields.

> <https://github.com/shotgunsoftware/tk-config-default2/blob/dd9fc5f08cc60823ade356142f440e0c33fe1494/core/templates.yml#L301>

project\_seq001\_sh0010\_dept\_version.ma.  
`@shot_root/work/maya/{name}.v{version}.{maya_extension}` would need updated to something like :-  
`@shot_root/work/maya/{project}_{sequence}_{shot}_{department}_{version}.ma`

> <https://github.com/shotgunsoftware/tk-config-default2/blob/dd9fc5f08cc60823ade356142f440e0c33fe1494/core/templates.yml#L512>

project\_prop\_walkingChair\_model\_v001  
`@asset_root/work/maya/{name}.v{version}.{maya_extension}` would need updated to something like :-  
`@asset_root/work/maya/{project}_{asset_type}_{asset}_{name}_v{version}`

It’s worth noting that including all the fields you want here may result in you exceeding the max character limit in winows filesystems, so normally workfiles do not include the project-code. The Shot code should include the sequence code, so you wouldn’t want to explicitly include both the sequence and shot code. Another reason for including the sequence code in the shot code is so the drop-downs in the web ui give you the full context of the shots listed; eg if you have 3 sequences each with shots 010, 020, 030. If you type 010, 3 010’s would appear and you wouldn’t know which sequences shot you want.

I would recommend starting by learning how this system works before making large changes to your templates. They are hard to debug for beginners if you break the config.

---

<div class="post-metadata">

**Author:** ![vikramj](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vikramj](https://community.shotgridsoftware.com/u/vikramj)\
**Post date:** [December 5, 2023, 1:11pm UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/5 "2023-12-05T13:11:23Z")

</div>

If anything breaks, I know you will help to bring the system back to running 🙂. As for the requirement, I need to go with what the management requires. I have highlighted to them the restrains but they need it this way. I will go ahead step by step.

---

<div class="post-metadata">

**Author:** ![vikramj](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vikramj](https://community.shotgridsoftware.com/u/vikramj)\
**Post date:** [December 8, 2023, 8:16am UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/6 "2023-12-08T08:16:01Z")

</div>

@Patrick , Thank you for your replies. While I have a need to add underscore to filename, I need to also remove {name} from the definition. How to remove {name} without getting error

“missing keys required for the publish template: [‘name’]”

---

<div class="post-metadata">

**Author:** ![Patrick](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrick/32/4767_2.png) [@Patrick](https://community.shotgridsoftware.com/u/Patrick)\
**Post date:** [December 8, 2023, 8:30am UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/7 "2023-12-08T08:30:17Z")

</div>

Can you share the template you are trying to implement?

---

<div class="post-metadata">

**Author:** ![vikramj](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vikramj](https://community.shotgridsoftware.com/u/vikramj)\
**Post date:** [December 8, 2023, 8:56am UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/8 "2023-12-08T08:56:21Z")

</div>

Copy pasting code here make the “_" disappear. I will attach the templates.yml here. you will need to search for "maya\_asset_” and “maya\_shot\_”

[templates.zip](https://community.shotgridsoftware.com/uploads/short-url/9EhwWVNYUu9iVibZsukfYzmWWFG.zip) (4.5 KB)

---

<div class="post-metadata">

**Author:** ![Patrick](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrick/32/4767_2.png) [@Patrick](https://community.shotgridsoftware.com/u/Patrick)\
**Post date:** [December 8, 2023, 9:17am UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/9 "2023-12-08T09:17:50Z")

</div>

> [@vikramj](#):
>
> missing keys required

The error is being raised either here :

> <https://github.com/shotgunsoftware/tk-maya/blob/dfe0f4cea6c14c6dcde0dea210e4f24b7829e128/hooks/tk-multi-publish2/basic/publish_session_geometry.py#L213>

or here:

> <https://github.com/shotgunsoftware/tk-multi-publish2/blob/f85dd39ba52f969c85024d9d35d557a0de20f00f/hooks/publish_file.py#L831>

You’ll need to add some debug logging here to see what fields you have at this point. Also which template is being queried. Can you confirm the name of the work and publish templates being queried at this point in the code?

Also, verify the publish template you have defined in your tk-multi-publish2 settings is maya\_asset\_publish.

SG is expecting to find a “name” field as it’s specified in a template being used for the publish. The odd thing is your maya\_asset\_publish template doesn’t have a name field, so I’m wondering if you’re not in an Asset task or the publisher has a different publish template defined?

What’s the filepath of the maya file you’re attempting to publish from?

---

<div class="post-metadata">

**Author:** ![vikramj](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vikramj](https://community.shotgridsoftware.com/u/vikramj)\
**Post date:** [December 8, 2023, 12:07pm UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/10 "2023-12-08T12:07:42Z")

</div>

@Patrick , I had close and open shotgun desktop to the changes to be reflected. Solved.  
Thank you for your efforts. Last question in this thread is how to add project to filename ?

---

<div class="post-metadata">

**Author:** ![Patrick](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrick/32/4767_2.png) [@Patrick](https://community.shotgridsoftware.com/u/Patrick)\
**Post date:** [December 8, 2023, 12:43pm UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/11 "2023-12-08T12:43:55Z")

</div>

Just add the project field to the template. It should pass through from the work template. If not, then you’ll need to customise the publish hook to get the project tankname from your context.

---

<div class="post-metadata">

**Author:** ![vikramj](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vikramj](https://community.shotgridsoftware.com/u/vikramj)\
**Post date:** [December 8, 2023, 1:50pm UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/12 "2023-12-08T13:50:07Z")

</div>

Thank you for your quick response.  
Including {project} in template is giving an error so I presume it is not passing through work template. How to customise the publish hook to get the project tankname from the context.

Where does this publish hook reside ?.  
Do you mean tk-multi-publish2 app. Where specifically ?

---

<div class="post-metadata">

**Author:** ![Patrick](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrick/32/4767_2.png) [@Patrick](https://community.shotgridsoftware.com/u/Patrick)\
**Post date:** [December 8, 2023, 2:02pm UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/13 "2023-12-08T14:02:19Z")

</div>

I’d start off with this video to get a better understanding of how the publisher works.

[![](https://global.discourse-cdn.com/shotgunsoftware/original/2X/b/b7f1411d9430f64f142fd76fa47e811550f3e4ee.jpeg "Shotgun Toolkit Webinar: The New Publisher API") ](https://www.youtube.com/watch?v=ZxP3IXHt47U)

---

<div class="post-metadata">

**Author:** ![Patrick](https://sea1.discourse-cdn.com/shotgunsoftware/user_avatar/community.shotgridsoftware.com/patrick/32/4767_2.png) [@Patrick](https://community.shotgridsoftware.com/u/Patrick)\
**Post date:** [December 8, 2023, 2:04pm UTC](https://community.shotgridsoftware.com/t/underscore-in-file-name-required/18219/14 "2023-12-08T14:04:09Z")

</div>

Also [Help](https://help.autodesk.com/view/SGDEV/ENU/?guid=SGD_vi_videos_html#shotgrid-toolkit-webinar-customizing-publish-workflows-a-live-demo-60m-)

[![](https://global.discourse-cdn.com/shotgunsoftware/original/2X/5/560ee9b8aa80fe97e674fd39bac480aafda05574.jpeg "Shotgun Toolkit Webinar: Customizing Publish Workflows - A Live Demo") ](https://www.youtube.com/watch?v=pH4mylrnktY)
