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
- Optional. The regex the filename will test against.
- Optional. regex the file's parent folders will test against.
- Optional. A list of valid file extensions for this type.
- One of
low
,medium
, orhigh
(will display as0
,5
, or9
). Higher values process first. - Optional. The default Shotgrid task to use if one cannot be parsed from the filename or parent folders.
- A mapping of filename values to template values. See Variable Maps
-
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
- The regex will capture the
version_name
,shot
, andtask
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)
version_name
is used to set the Shotgrid version name.task
is used to set the Shotgrid task. If not found, thedefault_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
- We parse a
version_type
from the filename. - Here we define a
var_map
for theversion_type
variable. DEFAULT
matches any other value. If theversion_type
is not one of the other keys, it will default toComp
.- If the
version_type
isvz
, it will map toVersionZero
.
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)!
...
- The file will download to
/shot/Development/
if the filename isshot_dev_v001.mov
. - The
version_type
variable can also still be used, so thesg_version_type
will be set todev
in Shotgrid.
-
Use
PCRE (Server)
as the RegEx Engine and enableglobal
andcase insensitive
flags for compatibility with Slingshot. ↩