Table of Contents goerke.tech
How to define names for photo files?

How to define names for photo files (and directories)?

Once you've selected one or more input files and/or folders by clicking the corresponding button in Photo Naminator and picking them in the Open Panel, Photo Naminator will start analyzing each file (also those in sub-folders recursively if you've selected the according option in Photo Naminator's settings pane) for its associated EXIF or TIFF metadata. This meta data consists of name/value pairs and is usually stored with the photo file when it is created by your smartphone or digital camera. Typical information contained is date and time when you took the photo, the lense used or aperture applied, etc.

Photo Naminator will create a dictionary of available meta data properties while analyzing the input files. Once the analysis has finished -- depending on the number of files this can take a few seconds – you will be able to select a pre-defined name pattern from the drop-down list, customize one of those patterns to match your needs or create a brand new one. Photo Naminator will store all those patterns conveniently for later re-use should you feel the desire to come back and rename more files at some point.

After the analysis of the input files and folders has taken place, Photo Naminator displays a list of all files with their current (or old) name, the new name they will get based on the currently defined name pattern and the time stamp associated with the photo file as well as the sequence number dynamically associated with the photo based on sorting them all by timestamp (and filename of there's several files with the exact same timestamp). This list will be helpful to you when changing the name pattern and determining the effect of your changes on the new names for the files. If you hover the mounse pointer above the current or new name, it will display the absolute directory paths of the associated file instances, so that you can check which file exactly was read or what path will be used to store the renamed file.

Name Patterns

Photo Naminator's purpose is to dynamically rename photo files using information contained in their associated meta data. Photo Naminator will therefore take a name pattern, that you can customize as needed, and apply it to each photo file to be renamed after replacing all placeholders in the name pattern.

Name Patterns

A name pattern is a sequence of literals (only those allowed for file names, which excludes e.g. the ':' character) interspersed with placeholders for photo meta data. When renaming a specific file, Photo Naminator replaces each placeholder with the respective value of the referenced meta data property. How the replacement exactly happens can be influenced by providing a formatting rule with the placeholder and optionally also conditional alternatives right after the formatting rule. More details are given below.

Creating a folder/directory structure dynamically

If a name pattern contains one or more '/' characters, Photo Naminator will interpret those as separators for folder/directory names. You can use this to not only rename photo files and have them copied 'flat' into the output folder, but have Photo Naminator create a sub-folder structure within the output folder where the renamed photo files will be placed. E.g. a name pattern './<DateTimeOriginal(yyyy)>/<DateTimeOriginal(MM)>/My_Photo_<sequenceNo(04)>.<fileExtension>' will result in a subfolder for each year in which a photo was taken to be created within the input folder or your selected output folder, and within those folders per year there will be folders for respective months, and within those you'll find your photo files with a 4 digit sequence number (the sequence number is an overall sequence number though, not per directory). You can of course use any placeholder to dynamically derive the directory names you want to be created.

Placeholders

A placeholder is placed into a name pattern by enclosing it in '<' and '>' characters: '<' placeholder '>' The name of a placeholder has to match a meta data property name in the respective photo file to which the name pattern gets applied. If a placeholder name does not match to any of the meta data property names of a photo file, it will be replaced with a "fallback" text (which you can override in the Photo Naminator settings pane). If a meta data property of a given placeholder name can be found in a specific photo file, it's said to be "defined", otherwise it's "undefined", which is important to note if using conditional alternatives.

As an example, the name pattern My_Photo_<DateTimeOriginal>.jpg references the EXIF DateTimeOriginal property of a photo and -- when applied -- will be expanded to e.g. My_Photo_2021-04-27T12_04_16_586+0100.jpg

You can of course place several placeholders anywhere into a name pattern. So here's another valid one: <sequenceNo>_<filename>_<DateTimeOriginal>.<fileExtension>. Here the new name for a file will start with its dynamically associated sequence number, followed by the input files original filename, followed by the photo creation timesstamp, and it gets the file extension of the original input file.

Formatting Rules

Each placeholder can be attributed with a formatting rule governing how the replacement will be formatted later on, and an optional conditional expression after the formatting rule. Formatting rules are placed into parentheses folloing the placeholder name (but before the closing '>' literal): '<' placeholder '(' formatting rule ')' '>'

  1. No or empty formatting rule: If no formatting rule is given (i.e. a placeholder is not followed by parentheses) or if the content within the parentheses is empty, Photo Naminator will apply a default formatting rule depending on the type of data the placeholder references.
  2. The 'suppression' formatting rule [depricated as of v1.56]: If you put the single character '-' (minus character) as formatting rule for any placeholder variable or place it as a prefix to any of the other formatting rules, the value of the placeholder will not be inserted into the new name. This is particularly useful if you want to use this placeholder only to distinguish whether it is defined or undefined in the meta data, and apply conditional alternatives instead. See below section on conditional replacement texts. Example: <DateTimeOriginal(-)> will always result in an empty character sequence in the name pattern, no matter what the DateTimeOriginal meta data property holds as a value or even whether it all exists.
  3. The suppression formatter has been depricated as of v1.56: it added unnecessary complexity to conditional formatting. As of v1.56 – whenever a conditional expression is used with a placeholder, the placeholder value will be automatically suppressed. In order to use the formatted placeholder, use '##' as part of the conditional expression itself. Make sure to adapt your custom patterns accordingly. See below paragraph about Conditional Alternatives for more details.

  4. Formatting rules for plain text data: If a placeholder references plain text data (i.e. no date and no number), it is by default replaced by the respective meta data's value as is. There are additional formatting capabilities available:

    If you place the literal 'U' within the parentheses or the literal 'L' or 'C', it will translate the value into uppercase, lowercase or "Camel"-case respectively. Additionally, following this optional case modifier you can specify a character range to trim the placeholder value to a substring. This is done by providing the first character position and the last character position of the substring, separated by "..". The first character of a string has index 1 (not 0!). Hence, the highest index of a string is denoted by the number of characters of that string value.

    Here's a few examples to clarify, assuming that the placeholder <filename> contains the value 'IMG_4711':

    • <filename(l1..4)> results in 'img_'.
    • <filename(c2..5)> results in 'Mg_4'.
    • <filename(2..)> results in 'MG_4711', i.e. if no last character index is given, the entire remaining string is taken.
    • <filename(c2..-2)> results in 'Mg_471', i.e. if the last character index is negative, counting of character offsets is done starting at the end, in this example: the second last character (= -2).
    • <filename(c-4..-2)> results in '471', i.e. if the starting or ending character index is negative, those indices will be taken as relative to the end of the placeholder value, i.e. in this example the 4th, 3rd and 2nd last characters.
    Any index outside the range of valid character indices of the particular placeholder value will be "normalized" to the valid lower (= 1) and upper (= length of value) bounds.
  5. Formatting rules for numbers: If a placeholder references data that represents a number, it is by default replaced by the respective value as is. You can control integer digits and fraction digits and the filler for integer digits though if you need more control over how numbers get formatted (you may want a fixed number of digits always, for example).

    In order to do so, the following number formatter can be specified: [' '|'0'|'_']integerDigits['.'fractionDigits]

    Here's a few examples to clarify:

    • <sequenceNo(04)> results in '0022' if the sequence number is 22.
    • <sequenceNo( 4)> results in ' 22' if the sequence number is 22.
    • <sequenceNo(_4.3)> results in '__22.000' if the sequence number is 22.
    • <sequenceNo(_4.0)> results in '__22' if the sequence number is 22.
  6. Formatting rules for dates: If a placeholder references data that represents a (known) date, it is by default replaced by the ISO representation of the timestamp (i.e. the format yyyy-MM-dd'T'hh:mm:ss.SSS ZZZ).

    Here's the list of allowed date formatters (careful, those are case sensitive!):

    • yyyy: Represents the year
    • MM: Represents the month (number: 1-12)
    • MMM: Represents the month (3-letter prefix of the month's name)
    • dd: Represents the day of month
    • hh or HH: Both represent the hours in 24h format (no more 12h format supported)
    • mm: Represents the minutes
    • ii: Same as mm, represents the mInutes, but is less error-prone than using mm which easily gets confused with MM (number of month)!
    • ss: Represents the seconds
    • SSS: Represents the milliseconds
    • ZZZ: Represents the timezone offset to GMT time ("+/-hhmm")
    • zzz: Represents the timezone as "GMT+/-hh"
    You can re-arrange these formatters as you like and separate them with different literals. If you want to place literals between those date/time formatters, make sure to enclose those literal within single (straight) quotes ('). Non-alphanumeric literals will do fine without the single quotation.

    Here's a few examples to clarify:

    • <DateTimeOriginal(dd_MM_yyyy)> results in '27_04_2021'.
    • <DateTimeOriginal(yy-MM-dd hh-mm-ss)> results in '21-04-27 12-34-56'.
    • <DateTimeOriginal(yyyy-MMM-dd'T'hh-mm-ss)> results in '2021-Apr-27T12-34-56'.
    • <DateTimeOriginal(yyyy-MM-ddThh-mm-ss)> results in '2021-04-ddThh-34-56'.
  7. Just as another reminder: those date formatters are case-sensitive! Make sure you're referring to the month (= MM) and not the minutes (= mm) accidentially. Seconds are lowercase ss, milliseconds is uppercase SSS. This can easily be confused.

    Photo Naminator actually uses the Mac's system date formatting function, which define the above formatting rules.

Conditional Alternatives

Between the closing parenthesis of any formatting rule and the closing bracket of a placeholder, you can optionally add two conditional alternatives for the replacement: one used in case the placeholder is defined (i.e. the photo file's meta data holds a corresponding property and the property's value is not empty), and one used in case the placeholder is undefined (i.e. there is no such corresponding property in the photo file's meta data present or the property's value is empty). The first alternative is defined as the characters you place after a '?' (questionmark) character, the latter is defined as the text you place after a ':' (colon) character. Either of the alternatives is optional. As of v1.56, the conditional alternatives given will be used instead of the placeholder's value in the name pattern, i.e. it automatically suppresses the placeholder value (prior version were appending the conditional alternatives to the placeholder value and you had to explicitely supporess this behaviour if you wanted something different). You can use the formatted placeholder value in the conditional alternative though referring to it via the '##' character sequence.

Here's how the conditional alternatives are defined: '<' placeholder '(' [formatting rule] ')' ['?' <text used when placeholder is defined >] [':' <text used when placeholder is undefined >] '>'

Let's provide a few simple examples to explain how this works. Let's assume the placeholder fileNameSubFolder1 is defined as 'Holidays2022', while fileNameSubFolder2 is not defined for the file we're currently looking at:

You can use the formatted property value in the (defined) alternative itself, by placing the sequence '##' into the alternative. Here's an example: Let's assume that the property 'fileNameDupNo' contains the value "2", then <fileNameDupNo(-04)?_##> will result in the placeholder evaluating to the character sequence '_0002'.

Getting help with name patterns

First, Photo Naminator comes with a list of predefined name patterns you can readily pick and use from the menu list in Photo Naminator. In this list, Photo Naminator will also store all the name patterns you define by yourself. If you want to delete one of your custom name patterns again so that it doesn't get stored for later use, simply delete all of its characters so that the "Custom" edit field is empty -- this will remove the pattern from the list automatically.

Second, Photo Naminator will dynamically present you a list of available placeholders from your input files as soon as you open a placeholder variable with the '<' tag. The list will be showing those placeholders that are available in the photo files' meta data and that match the placeholder prefix that you have typed in so far. If your custom name pattern for example currently is '<Date', the list will show 'DateTimeOriginal', 'DateTimeDigitized', 'FileDateTimeCreated' and 'FileDateTimeModified'. You can click on an entry in the selection list of matching placeholders and it will be automatically copied into the name pattern edit field. (I unfortunately haven't managed yet to allow you to use the tab and cursor up and down keys to automatically select and copy one of the matching patterns, i.e. auto-complete is not yet possible...).

As you select a predefined name pattern or as you type and create your own custom one, Photo Naminator will immediately update the new name of all the files in the list displayed below. This way you can check what your editing will result in and where you are potentially making spelling errors -- or information is missing in a particular photo file (.e.g the placeholder "Aperture" may not exist for all your input files and still you're trying to reference it in a name).

If your name pattern yields a valid new file name, i.e. all placeholders could be validly replaced with their respective values from the photo file, it will show a little green checkmark next to the new file name. Should there be any undefined placeholders for a particular photo file, there will be a red or orange exclamation sign instead.

Some special placeholders

Photo Naminator exctracts information from your photo files by looking at their EXIF or TIFF metadata. It will also add the following placeholders derived e.g. from the photo file's actual filename or file properties:

Timestamp properties

Geolocation properties

The following geolocation properties will only be defined if ...

File properties

The above formatting rules apply to those special placeholders as well.

Handling undefined placeholders

Photo Naminator will replace any undefined placeholder with a 'fallback' literal (by default that's '_??_'). You can override this with your own fallback text (or empty) in Photo Naminator's preferences section.

If your name pattern yields a valid new file name, i.e. all placeholders could be validly replaced with their respective values from the photo file, it will show a little green checkmark next to the new file name. Should there be any undefined placeholders for a particular photo file, there will be a red or orange exclamation sign instead.

By default, Photo Naminator will not process any files whose new name could not validly constructed (i.e. where a placeholder could not be replaced with a respective value (not the fallback)). If this is the case, you'll see a red exclamation symbol to the right of the new file name of the photo file. You can override this strict behaviour of not processing those files in Photo Naminator's preferences and ask Photo Naminator to also process those files (the 'fallback' literal will be used instead of the undefined placeholder values then).

Previous page Back to top Next page