Find all local broken links for Published Files

Hi all!

If Shotgrid Desktop app is opened, we can open files directly clicking on the path field of the Shotgrid Web UI. And if the link is broken we get a “Local File Linking Error” on the web UI.

So I wonder if there could be a way to query all the broken links. The links that don’t have the corresponding file on the disk any more.

Any idea?

Thanks in advance :slight_smile:

Sorry, but how you did to open the local file link on the web ?

I don’t think such a thing exists, but it is easy to achieve with the api. You could execute this anywhere - in a tank shell, in Houdini, Nuke

import os
# e.g. all Houdini scenes. You probably need some filter, or you might get tons of data.
publishes = shotgun.find("PublishedFile", [["published_file_type", "name_is", "Houdini Scene"]], ["path"])
for publish in publishes:
  if not os.path.exists(publish["path"]["local_path_windows"]):
    print("File does not exist {}".format(publish["path"]["local_path_windows"]))

Hi @Francesc_Macià I’m referring to the ability of launching a Maya’s local instance clicking directly on the SG web UI “path” field for a Published .ma file.

This is the default behavior when you have the Shotgrid desktop app opened in background.


1 Like

Thank you very much for your answer @mmoshev

I have tried it and I’m not managing to get it working…

Just to be sure:

  1. Are you sure that [“local_path_windows”] exists in SG? I can’t find it…

  2. And also, just to be sure that I’m being clear enough:
    What I need is not to check that the “Path” field is filled. I need to check if the file path, visible when I do a mouse over on the “Path” value, has or not a broken local link to the file that should be on our file server. This screenshot should help.


Thank you again, your help is greatly appreciated!!

Hi, local_path_windows is part of the path field of a PublishedFile entity, as this field its a “complex” field (This can be different depending on how you set this field) you can’t see on the Web UI, what mmoshev is saying with his code is:

  • query the PublishedFiles records
  • check if the path exists
  • do something, like save the data to a file

If you need something for the Web UI you will need a special implementation from the toolkit or maybe an Accion Menu Item (I dont know if this can be possible with this but you could try):


Thank you very much guys!

I’m getting some results here, but I’m not sure they are reliable.

After 42 results I’m get this error too:

Any idea of what am I doing wrong?

I’m launching the script from this .py