2 2

6 posts in this topic

@UrbanCircus I pieced together getting files created from an action but unfortunately haven't made any progress to populate the directories based on the structure of my project.

import logging
import ftrack_api
import errno
import os

class MyCustomAction(object):
    '''Custom action.'''

    label = 'createfolders'
    identifier = 'my.custom.action'
    description = 'This is an example action creating folders'

    def __init__(self, session):
        '''Initialise action.'''
        super(MyCustomAction, self).__init__()
        self.session = session
        self.logger = logging.getLogger(
            __name__ + '.' + self.__class__.__name__

    def register(self):
        '''Register action.'''
            ' and source.user.username={0}'.format(

            'topic=ftrack.action.launch and data.actionIdentifier={0} and '

    def discover(self, event):
        '''Return action config if triggered on a single asset version.'''
        # If selection contains more than one item return early since
        # this action can only handle a single version.
        selection = event['data']['selection']'Got selection: {0}'.format(selection))
        # action works in the task context
        if len(selection) != 1 or selection[0]['entityType'] != 'task':

        return {
            'items': [{
                'label': self.label,
                'description': self.description,
                'actionIdentifier': self.identifier

    def launch(self, event):

        '''Callback method for custom action.'''
        path = 'C:\\project\\test\\'

        except OSError as error:
            if error.errno != errno.EEXIST:

        return {
            'success': True,
            'message': 'did it work?'

def register(session, **kw):
    '''Register plugin.'''

    # Validate that session is an instance of ftrack_api.Session. If not,
    # assume that register is being called from an incompatible API
    # and return without doing anything.
    if not isinstance(session, ftrack_api.Session):
        # Exit to avoid registering this plugin again.

    action = MyCustomAction(session)

if __name__ == '__main__':
    session = ftrack_api.Session()

    # Wait for events.


Share this post

Link to post
Share on other sites

Ftrack will trigger folder creation once you publish but only the structure that is needed for the task not the overall project folder structure that is in Ftrack.

This seems like a basic requirement as users creating folders manually will nearly always make spelling mistakes i.e. there will be differences between the folder structure on server and on ftrack.

This means due to user error Ftrack will dump versions in the "wrong" location.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
2 2