Skip to content

File Types

File Types make up the different, pre-configured types of files that Slingshot can recognize.

They are used to extract metadata and determine how to process each file through the pipeline.

Every incoming file is checked against the regex, parent_folders_regex, and extensions of each configured file type in order, and the first match is used to determine the item's type.

Configuration

ingest:
  file_types:
    - name: shot
      examples: [101_010_0010_v001.mov, 201_200_0200_v0002.mp4] # (7)!
      regex: ^(?P<version_name>(?P<shot>\d{3}_\d{3}_\d{4})_v\d{3,4}) # (1)!
      parent_folders_regex: null # (2)!
      extensions: # (3)!
        - mov
        - mp4
      priority: 9 # (4)!
      default_task: null # (5)!
      var_map: # (6)!
        task:
          DEFAULT: Comp
          dev: Development
          ref: reference
  1. Optional. The regex the filename will test against.
  2. Optional. regex the file's parent folders will test against.
  3. Optional. A list of valid file extensions for this type.
  4. One of low, medium, or high (will display as 0, 5, or 9). Higher values process first.
  5. Optional. The default Shotgrid task to use if one cannot be parsed from the filename or parent folders.
  6. A mapping of filename values to template values. See Variable Maps
  7. Examples are a list of sample filenames for this file type. If no examples are provided, three will be generated randomly from the configured regexes.

    If examples are provided, they will be validated to make sure they match the current file type as configured. They'll also be checked to make sure they don't match any earlier, higher priority file_types.

Order Matters

Slingshot searches for matches from the top down, in the order configured.

If a file matches multiple file types, the first match will be used.

Unknown Files

If no match is found, the item type remains None.

You can still process items with no type in some actions (like the UNKNOWN special keyword in the download module), but no metadata will be extracted from the filename or parent folders.

Regular Expressions

Regular expressions (regex) are used to match filenames and parent folders to determine the item type. They can also be used to extract values from the filename or parent folders for later use in a pipeline.

A good resource for creating and testing regex is regexr.com1

Capture Groups

Regex capture groups are used to extract values from the filename or parent folders. They are defined in the regex using (?P<name>...) syntax.

The captured values can be used in templated strings as $name.

Example
ingest:
  file_types:
    - name: shot
      regex: (?P<version_name>(?P<shot>\w+)_(?P<task>\w+)_v\d+) # (1)!
  1. The regex will capture the version_name, shot, and task from the filename.
Filename $version_name $shot $task
shot1_comp_v001.mov shot1_comp_v001 shot1 comp
shot2_ref_v002.mov shot2_ref_v002 shot2 ref
shot3_dev_v003.mov shot3_dev_v001 shot3 dev

Required Shotgrid Capture Groups

The add_to_shotgrid module looks for special hard-coded capture groups. These are:

  • version_name (required) (1)
  • task (optional) (2)
  1. version_name is used to set the Shotgrid version name.
  2. task is used to set the Shotgrid task. If not found, the default_task will be used instead.

Variable Maps

Variable maps allow you to map values captured by the regex to other values.

For example, filenames may contain the string dev, but you want them to download to a folder called Development. You can map dev to Development here and use the mapped value in templated strings.

ingest:
  file_types:
    - name: shot
      regex: (?P<shot>\w+)_(?P<version_type>\w+)_v\d+ # (1)!
      ...
      var_map:
        version_type: # (2)!
          DEFAULT: Comp # (3)!
          vz: VersionZero # (4)!
          tr: Trailer
          dev: Development
  1. We parse a version_type from the filename.
  2. Here we define a var_map for the version_type variable.
  3. DEFAULT matches any other value. If the version_type is not one of the other keys, it will default to Comp.
  4. If the version_type is vz, it will map to VersionZero.

We can now access the mapped value in templated strings as $version_type_mapped:

Filename $version_type $version_type_mapped
shot_vz_v001.mov vz VersionZero
shot_tr_v001.mov tr Trailer
shot_dev_v001.mov dev Development
shot_comp_v001.mov comp Comp
shot_other_v001.mov other Comp
actions:
  - module: download
    paths:
      shot: /$shot/$version_type_mapped/ # (1)!
  - module: add_to_shotgrid
    file_types:
      shot:
        sg_version_extra_data:
          sg_version_type: $version_type # (2)!
        ...
  1. The file will download to /shot/Development/ if the filename is shot_dev_v001.mov.
  2. The version_type variable can also still be used, so the sg_version_type will be set to dev in Shotgrid.

  1. Use PCRE (Server) as the RegEx Engine and enable global and case insensitive flags for compatibility with Slingshot.