Prevent folder creation depending on Asset type


I have a certain asset type that I’d like to prevent certain folders from being populated in on folder creation.

For example I have a scripts directory that should only be created for a certain type of asset. I added a scripts.yml file alongside of it. The parent directory of this files is called “Asset” where it will dynamically pick up the name of the asset type when run.

in the scripts.yml file I have:

type: "static"
constrain_by_entity: "$asset"

    - { "path": "sg_asset_Type", "relation": "not_in", "values": ["Stuff"] }

Where $asset is my parent folder (I assume) and I’m trying to say with the constraints “Hey, don’t create this folder if you are of asset type Stuff”

However this does not work as expected and I get the error when I run this create folders hook:

\blah\blah\blah\scripts: constrain_by_entity '$asset' could not be resolved into a parent node. It needs to be on the form '$name', where name is the name of a parent yaml configuration file.

Where I have no idea what “name” it’s referring to.

Any idea where I’m going wrong?



Any takers on this? There seems to be some significant gaps in the file system reference documentation.
From the section on static folders in

#pick one of the shotgun folders that are above this folder
#in the folder hierarchy. In this case it is a parent folder
#named step that we want to look at when deciding if this
#static folder should be created or not.
constrain_by_entity: “$step”

$step is referring to an actual folder named step? A shotgun field? a yml file? I can’t make heads or tails of this. In my actual “asset” folder of my schema I have contraints defined by $asset that work (asset being the parent folder and I’m able to prevent creation of static directories by using constrain_by_entity: $asset. However in the folder above this (asset_type) I am unable to use $asset_type or $asset as the entity constraint.

The schema is (briefly) as follows:


  • asset_type
    – scripts
    – scripts.yml
    – asset (contains a Data folder and Data.yml)
    – asset.yml

where the Data folder only creates for certain asset types. However I’d also like the scripts folder to only create for certain asset types as well but it has to be be a parent of the asset_type folder.
Hence I thought “Oh, I should constain by the asset entity” but that just doesn’t work in this case.
So I literally thought that the constrain_by_entity variable wanted the name of the containing folder ie asset_type but that also doesn’t work.

What are the cases where constraints will work, then?


1 Like

Hey! Apologies for letting this one sit! What you have should work and matches what’s described in the File System Configuration Reference. I’m going to see if I can repro what you’re seeing (and figure out where it’s going south). Will report back!

1 Like

Hi again – I went through about three iterations of a reply here, and sadly, I’m not sure you can do what you’re seeking to do.

In the static folder creation code in tk-core, it’s actually taking the constraints value, “translating” its syntax a bit, and feeding it directly to a find_one() query in the Shotgun API:

If it doesn’t match the constraints, it returns without creating the folder.

It order to do that find_one(), it has to have an entity. So the parent folder that you’re basing your constraint on needs to be of type shotgun_entity. In your case, you do have a shotgun_entity folder, asset, but it’s not the parent of scripts, it sits parallel to it. And the actual parent folder, asset_type is not of type shotgun_entity, but shotgun_list_field. Which puts you in a bit of a bind.

I tried one other thing: You can manually specify a parent with the associated_entity_type setting. I tried setting that to Asset in scripts.yml, but I got the same error you did. It looks like associated_entity_type doesn’t work with static folders, but it may also be the case that you can’t specify a parent that’s not above the current folder in the hierarchy.

All that to say, I empathize with your frustration here. I’m going to run this by the team and see if anyone has any better ideas as to how to move forward here. It’s possible someone has some deeper schema knowledge than I do (the more advanced stuff is a bit of a dark art), but if not, I wonder if it would be as simple as supporting associated_entity_type for static folders.

I’ll keep you posted on what I find. Sorry it’s not better news!

1 Like

Thank you for looking into this! Hopefully someone skilled in the dark arts has a work around.

While we’re on the subject, I’m also trying to create a dynamic step folder but only if the asset is of a certain type.

here’s the code for Design.yml (to be paired with a Design folder)

type: shotgun_step
name: short_name
    - { "path": "sg_asset_type", "relation": "in", "values": ["Editorial"] }

What I mean to do is make the folder named after the step only if the parent asset type is “Editorial”. The parent folder is Asset, btw.

Is there a way to make this happen?


1 Like

Hey there,

Any updates regarding my last post?