# metadata_mapping rules files can live in GSDLHOME/etc or in a collection's etc folder.

# Each line of the metadata_mapping_rules comma-separated value file must consist of 5 entries

# 1. Source metadata name to use
# 2. Source Regex it needs to match
#      This must start with either 's/...' or 'm/...'
#      's' means the line is a straight substitution rule, which is always
#         applied to generate the destination metadata name+value. If no
#         substitution happens, the resulting metadata element will have the
#         same value as the original.
#      'm' means the line must match the regular expression before the
#         substitution rule is applied to generate the destination metadata
#         name+value. If no match, then the destination metadata won't be
#         generated.

# 3. Destination Regex substitution
# 4. Regex modifiers (e.g. 'i' for case-insensitive, 'g' for global)
# 5. Destination metadata name to set with the modified value
# It is ok to have comments after the 5 entries, starting with #

Source,                   s/\.\w+$/,                  // ,      '' , _transientSourceTitle1     # removes filename extension from end
_transientSourceTitle1,   s/([A-Z][a-z]+)(?=[A-Z])/,  /$1 /,    'g', _transientSourceTitle2     # break up CamelCase 
_transientSourceTitle2,   s/(_|-)+/,                  / /,      'g', ex.SourceTitle             # reduce sequences of underscores and/or hyphens to a single space per sequence


# Say your filenames are in the form yyyymmdd-Author - to extract Date and Author from this, do something like:
#Source,   m/^(\d{8}).*/,   /$1/,  '', ex.Date   # extracts the 8 starting digits as date. because it starts with m, ex.Date won't be generated for Source metadata that doesn't start with 8 digits.
#Source,   m/^(\d+).*/,   /$1/,  '', ex.Date   # alternatively, extract all the starting digits as date - use eg if you have a mixture of yyyymmdd, yyyymm, yyyy
#Source,  s/^\d{8}-/,   //,  '', ex.Author  # removes the starting 8 digits and hyphen, and the result becomes ex.Author. because its an 's', ex.Author will always be generated. If the regex doesn't match, then ex.Author will have the same value as Source
#Source,  s/^\d+-/,   //,  '', ex.Author  # alternatively, removes all the starting digits and hyphen, and the result becomes ex.Author


