Underscore in file name required

ksnip_20231204-115712

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

1 Like

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?

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.

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.

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.

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

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.

If anything breaks, I know you will help to bring the system back to running :slightly_smiling_face:. 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.

@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’]”

Can you share the template you are trying to implement?

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 (4.5 KB)

The error is being raised either here :

or here:

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?

@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 ?

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.

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 ?

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

Also Help