Registering sandbox directories on behalf of users

Hello! I am doing a mass migration from one shotgun instance to another. I need to copy artists scene files to their new individual sandbox areas and I would love it if tk-multi-loader would be able to display their work scenes when I click “Show Files for All Other Users”. I know this would happen if they launched Maya within the asset’s context, but I’m looking for a shortcut. I followed the instructions on this post to no avail:

Any tips?
Thank you!


Hello Justin!

Welcome to the forums!

Just checking but I think this might be a typo, the tk-multi-loader2 doesn’t have that option, but the tk-multi-workfiles2 does.

The Workfiles app requires that file paths conform to the templates and that the folders are registered, in order for them to show up. If your moving stuff from one SG site to another, the things to check would be:

  • Are you using the same config as the other site’s project? Most importantly are the template and schema are the same?
  • Have you tested generating a new user scene file, through the workfiles app and then seeing if another user can see it when selecting “Show Files For All Other Users”? If this isn’t working then this needs to be solved first before trying to transfer the files.
  • Assuming the above works, compare your copied files to your new file, and make sure that the copied ones are in the correct location.
  • Make sure the user folders are registered. Now, this is where the steps in the other topic come in. When you say they didn’t work for you, I presume it ran without error, but just didn’t solve the issue? What you can do to check is, if the script has run correctly then you should end up with a bunch of FilesystemLocation entities in Shotgun for that user. If they don’t exist then workfiles won’t recognise the files.
    Knowing if they exist will tell us if the script did what it was supposed to.

Hopefully, that helps, but if not we’ll help you dig in.



Thank you for the quick reply, Phil! You are correct, I meant tk-multi-workfiles2. Sorry about that.

I am pretty sure everything is in the correct location. My files are in a similar spot and they show up just fine. The user’s files would show up if they opened shotgun with that context.

When I check the filesystem locations, I see only one entry for my sample prop and it’s at the top level. From the Shotgun Desktop python console I ran the unregister_folders command followed by the steps outlined in the quoted topic (set FOLDERUSER env, set g_shotgun_current_user_cache to unknown, run create_filesystem_structure for the asset). This creates a series of filesystem locations associated with me rather than the username that I had provided.

From here, I am guessing that I did something wrong on my end. I have double-checked that I am using the correct pipeline configuration with my local changes. Below is what I am running followed by the log output:

import sgtk
from sgtk.util import login
import os

cmd = sgtk.platform.current_engine().sgtk.get_command("unregister_folders")
cmd.execute({"path": "/path/to/myasset"})
os.environ['FOLDERUSER'] = 'theguy'
login.g_shotgun_current_user_cache = "unknown"
tk.create_filesystem_structure("Asset", 4000, engine="tk-maya")
2019-09-13 10:39:42,254 [    INFO] [PROXY] Unregister complete. 13 paths were unregistered.
2019-09-13 10:39:45,104 [   DEBUG] [PROXY] Path cache sync tracking marker in local sqlite db: 9922075
2019-09-13 10:39:45,108 [   DEBUG] [PROXY] Fetching create/delete folder event log entries >= id 9922075 for project {'type': 'Project', 'id': 93}...
2019-09-13 10:39:46,136 [   DEBUG] [PROXY] Got 1 event log entries
2019-09-13 10:39:46,140 [   DEBUG] [PROXY] Event log contains 0 creations and 1 deletions
2019-09-13 10:39:46,143 [   DEBUG] [PROXY] Path cache syncing not necessary - local folders already up to date!
2019-09-13 10:39:46,623 [   DEBUG] [PROXY] Uploading 13 path entries to Shotgun...
2019-09-13 10:39:47,545 [   DEBUG] [PROXY] Creating event log entry {'event_type': 'Toolkit_Folders_Create', 'entity': {'type': 'PipelineConfiguration', 'id': 15}, 'project': {'type': 'Project', 'id': 93}, 'meta': {'core_api_version': 'v0.18.164', 'sg_folder_ids': [81323, 81324, 81325, 81326, 81327, 81328, 81329, 81330, 81331, 81332, 81333, 81334, 81335]}, 'user': {'name': 'Justin Onstine', 'firstname': 'Justin', 'lastname': 'Onstine', 'image': None, 'email': <my_email>, 'login': 'jonstine', 'type': 'HumanUser', 'id': 111}, 'description': 'Toolkit v0.18.164: Created folders on disk for Tasks with id: 13571'}

Thanks again for your help, I really appreciate it!


Ah! I think my example is missing a crucial detail that I was taking for granted.

If the sgtk API is authenticated with user credentials then it won’t call the core hook, as it will just take the user from the current credentials. So in order for this to work you would need to use script authentication.
You can add the following to the beginning of your script, (you need to replace the API script name and key with your own.)

import sgtk
from sgtk.util import login
from tank_vendor.shotgun_authentication import ShotgunAuthenticator

cdm = sgtk.util.CoreDefaultsManager()

authenticator = ShotgunAuthenticator(cdm)

user = authenticator.create_script_user(


# # create an sgtk api instance
project_id = 137
tk = sgtk.sgtk_from_entity("Project",project_id)

I’ll update my original topic post as well. Sorry about that, hopefully that should be the missing part.



Ah, ok great! I was sort of wondering about that, actually. Thank you very much!!