Path argument for ui.openExplorer()

Perhaps there is already a way to do this that I missed, but I would really like a native TD method for browsing to a file or folder on my file system. I currently am doing some things with the subprocess and os modules, but I can’t seem to consistently make the new window open in focus above my TD windows, and it seems unnecessarily complicated when we can already get an external browser to the project folder with openExplorer().

Is there something implemented already, or is it possible to add an argument so that the method is openExplorer(path=project.folder) as a default?

@drmbt

You can us ui.viewFile() to open a folder in explorer. Window focus seems good on my system, but is always tricky. If you can create a case where it’s wrong using this technique, please post again.

ui.viewFile opens the file itself. I could do some janky splitting to get the parent directory, but the behavior I’m hoping for is to highlight the file in the windows explorer, so just getting the parent folder doesn’t speed things up when I’m diving into a folder full of assets. My current script looks like this, but doesn’t open above any TD processes, which will get confusing for end users that don’t know to look behind their program:

import os
import subprocess
FILEBROWSER_PATH = os.path.join(os.getenv('WINDIR'), 'explorer.exe')
filePath = parent(2).op('item')[1,'path'].val
filePath = os.path.normpath(str(filePath))
if os.path.isdir(filePath):
    subprocess.run([FILEBROWSER_PATH, str(filePath)])
elif os.path.isfile(filePath):
    subprocess.run([FILEBROWSER_PATH, '/select,', str(filePath)])

Maybe this is more a python question for Stack Overflow at this point, but a ui.openExplorer argument like my RFE would make this easier if TD had a native way to handle it, or an argument for ui.viewFile() that doens’t try to launch the file but just browses to it