Creating and unregistering folders with the event daemon

A question we get asked is can you automatically create Toolkit folders on disk via the Shotgun event daemon. For example, once a user creates a new asset in Shotgun, can the event daemon automatically detect this and run the folder creation for the asset?

Also similar to the above, can you automatically detect entities being renamed in Shotgun and then unregister the existing folders with the old name and recreate them based on the new name.

We would say that whilst it may be possible, we wouldn’t recommend using the event daemon to unregister or create folders automatically. There are a number of reasons why:

  • If you were to only unregister the folders and then create them again, this wouldn’t delete the old folders, or move the files that were already contained within them. So you would need to move these files to the new folders.
  • Once you move the files, it may impact things like references within those files or others, where the paths have now changed.
  • Any PublishedFile entities or Versions with paths pointing to the folders will also need to be updated.
  • Even just creating the folders automatically when an entity gets created may be a bad idea. As it will not give the user a chance to rename the entity if they initially got it wrong.

Suggestions

One suggestion would be to lock down the permissions for renaming shots and assets so that artists must come to the Shotgun admin to get things renamed. That way you can ensure everything gets linked up properly.

Another approach would be to create a separate field on the asset and shot entities to drive the folder names. You would change the permissions on this field so that artists can’t directly edit it. You could then use the event daemon to initially 1 time populate the folder name field based on the entity’s name, or have a script that the user runs to create the folders and populate the folder name field at the same time. This way the artist can later rename the Shot or Asset but the folders won’t automatically change.