Regular Expressions for files and folder naming.
Ramses uses specific file and folder naming conventions. Here are useful regular expressions to manipulate them.
Note
All names used by Ramses should be compated ignoring the case. Thus all regular expressions should use the i
flag.
Short Names (IDs)
/^(?!(?:NO|STB|TODO|WIP|OK|PUB|V)?[0-9]+)[a-zA-Z0-9+-]{1,10}$/gi
Short names, or IDs are made exclusively of a-z
, A-Z,
0-1and
+-` characters, and cannot be more than 10 characters.
The negative part of the regular expression, (?!(?:NO|STB|TODO|WIP|OK|PUB|V)?[0-9]+)
, is used to differenciate regular blocks (name, short name, etc.) from versions.
Names
/^(?!(?:NO|STB|TODO|WIP|OK|PUB|V)?[0-9]+)[ a-zA-Z0-9+-]{1,256}$/gi
Names made exclusively of a-z
, A-Z
, 0-1
, +-
and the space characters, and cannot be more than 256 characters.
Warning
Names should never be used in file names, as it may generate paths which may be very long.
The negative part of the regular expression, (?!(?:NO|STB|TODO|WIP|OK|PUB|V)?[0-9]+)
, is used to differenciate regular blocks (name, short name, etc.) from versions.
Status and versions
/(NO|STB|TODO|WIP|OK|PUB|V)?([0-9]+)/gi
The first matching group contains the status (and may be empty), and the second group is the version number.
Note
The string in the first matching group should be dynamically built using the list of available status IDs (short names). By default, it should at least contain the default states: NO, STB, TODO, WIP, OK, PUB, V.
Extract version from a file name
/(?:(_(NO|STB|TODO|WIP|OK|PUB|V)?([0-9]+)))(?:\.[a-z0-9.]+)?$/gi
This regular expressions matches everything including the last underscore, the version block and the file extension if any.
The first group contains the underscore and the version block; it can be used to be replaced by an empty string in file names to quickly remove the version block from the name.
The second and third groups contain the state and the version.
Resource names
/(?!(?:NO|STB|TODO|WIP|OK|PUB|V)?[0-9]+)[a-z0-9+\s-]+/gi
Resource names can be made of a-z
, 0-9
, +-
and white spaces but must not start with a version scheme.
File names
This is the regular expression for validating, matching and decomposing file names.
/^([a-z0-9+-]{1,10})_(?:([ASG])_((?!(?:NO|STB|TODO|WIP|OK|PUB|V)?[0-9]+)[a-z0-9+-]{1,10}))(?:_((?!(?:NO|STB|TODO|WIP|OK|PUB|V)?[0-9]+)[a-z0-9+-]{1,10}))?(?:_((?!(?:NO|STB|TODO|WIP|OK|PUB|V)?[0-9]+)[a-z0-9+\s-]+))?(?:_(NO|STB|TODO|WIP|OK|PUB|V)?([0-9]+))?(?:\.([a-z0-9.]+))?$/gi
Here is the list of matching groups:
- Project ID
- Type: A (Asset) or S (Shot) or empty (for general items)
- Asset or Shot ID or empty (for general items)
- Type: G (General) or empty
- Step ID
- Resource name or empty
- Status or empty
- Version number or empty
- Extension or empty
If any string does not match this regular expression, it means it does not follow the Ramses naming scheme.
Master media file names
/^([a-z0-9+-]{1,10})_([a-z0-9]{1,10})(?:-([a-z0-9]{1,10})?)_(\d+)x(\d+)(i|p)?_(\d+\.?\d*)(?:fps)?(?:_([a-z]+))?(?:_([a-z]+)st)\.([a-z0-9.]+)/gi
Here is the list of matching groups:
- Project ID
- Codec ID
- Colorspace ID
- Width
- Height
- p (progressive), i (interlaced), or empty
- Framerate
- Language or empty
- Subtitles language or empty
- Extension