# Rename Template Editor

The Preferences-Rename template editor is used to create and modify rename templates.

The Template name field is the unique name associated with the template.

Tabs and newline characters may be used to provide formatting to make it easier to read the template. They are ignored when utilizing the template. Space characters are meaningful and are displayed as a centered-dot character to make it easier to see them. The Format button can be used to apply formatting to the current template. If for any reason you want to remove the formatting and display the template as a single line of text, hold down the Shift key and click on the Format button.

Tokens are inserted via the Add Token button or via the context menu. Holding down the Control key while entering an alphabetic character will display an abbreviated menu displaying only those menu items beginning with the specified character.

The font size can be changed by Font>Bigger (⌘+) and Font>Smaller(⌘-)

You can preview and optionally apply the template by the Preview button.

A template can optionally specify any of the case transformation operations described in Alphabetic Case Transformations.

You can optionally choose to apply Name Exceptions, General Exceptions and Replacements. More information on exceptions can be found in Preferences - Rename Exceptions.

Spaces to underscores will cause all space characters to be replaced by underscore characters.

Force Latin-1 attempts to ensure that every character in the result can be represented as an ISO Latin-1 character. It does so by changing various characters to their similar ISO Latin-1 equivalents, removing accents if necessary and as a last resort by changing characters which cannot be represented as ISO Latin-1 to underscore characters. Unicode UNFC, and Fold Characters are applied. See the Re-Encode action statement for more information.

Remove accents will attempt to remove all accents from characters. Note that Force Latin-1 will not remove accents from valid ISO-Latin-1 characters.

The Finder has the ability to show or hide filename extensions. When renaming files you can elect to leave the current setting unmodified or to force the state to Hide or Show. Note that any change to the show/hide state is only made if a file is actually renamed.

The Template field describes how the new filename is composed. You may place text or tokens into the definition. Note that the tokens are entered by clicking on the + button. For ease of access, some tokens are placed in submenus. The following list describes the tokens which do not simply map to a field or property.

> Album Artist
>   Inserts the contents of the Album Artist field. If the field is empty Artist will be used.
> Break
>   The template field holds tokens and strings of text. The IfLength and Truncate tokens must be followed by an integer value. If you want to follow the integer value by a text sequence you will have to separate the two sequences with a Break token.
>   eg. truncate the result to twenty characters and insert ...
>   ❨Truncate❩20❨Break❩;...
> Disc>Disc Pad2
>   Inserts the contents of the Disc field, padded if necessary, with a leading zero so that the field occupies two characters.
> Disc>Disc Pad3
>   Inserts the contents of the Disc field, padded if necessary, with up to two leading zeros so that the field occupies three characters.
> Disc>Disc Smart Pad
>   Inserts the contents of the Disc field, padded if necessary, with leading zeros so that the width is consistent across an album for the maximum number of discs. The padding will only occur if there are ten or more discs in the album. The Disc Count determines the maximum number of discs.
> Dup #
>   This token is only valid when inside an IfDup sequence. When the token is present and a filename is a duplicate, it will be replaced by the first number 2, 3, 4, etc. which causes the filename to be unique. Note that this token is only valid when the template is being used by a Rename operation. It is not valid in Move, Copy, etc. action functions.
> Episode>Episode Pad2
>   Inserts the contents of the Episode field, padded if necessary, with a leading zero so that the field occupies two characters.
> Episode>Episode Pad3
>   Inserts the contents of the Episode field, padded if necessary, with a leading zero so that the field occupies three characters.
> Flow Control>Else
>   Marks the end of the true processing for an If construct. Everything after the optional Else token is processed up to the next EndIf, Folder Start or end of the template if the condition was false.
> Flow Control>endIf
>   Marks the end of processing for an If construct. endIF statements may be omitted at the end of a template and before a Folder Start token.
> Flow Control>IfCompilation
>   This token is used to test if the file is part of a compilation. The detrmination is based on the Part of a Compilation field. If the condition is true, all tokens and text until the next associated Else or endIf will be processed.
> Flow Control>IfDup
>   Everything between IfDup and endIf tokens is treated as a repair section to handle the case where files cannot be renamed because the name already exists. It is not uncommon for albums to have more than one track named intro or introduction. If you are renaming all tracks in an album to the title of the track, the rename will fail because more than one track has the same name. IfDup-endIf sections are only used in this case.
> Flow Control>IfExists
>   The IFExists tokens are used to test if a field exists (is non empty). If the specified field exists all tokens and text until the next associated Else or endIf will be processed.
> Flow Control>IfExists+
>   The IFExists+ tokens are a typing convenience. ❨IfExists+ Album❩ ... is equivalent to ❨IfExists Album❩ ❨Album❩ .... It is used when you want to insert the field being tested.
> Flow Control>IfLength integer
>   This token is used to test if the current length of the name being constructed is greater than the value specified in the following integer. If it is, all tokens and text until the next associated Else or endIf will be processed.
>   eg. Truncate the name if it is greater than 100 characters.
>   ❨IfLength❩100❨Truncate❩100❨Break❩;
>   See Filename Lengths for special semantics used when the length field is negative.
> Flow Control>IfMultiDisc
>   This token is used to test if the file is part of a multi disc album. A file is considered part of a multi disc album if at least one of the Disc or Disc Count fields is greater than 1. If the condition is true, all tokens and text until the next associated Else or endIf will be processed.
> Flow Control>Folder Start
>   This token marks the start of the template used to rename the folder of the file being renamed. The folder portion extends until the end of the template. If there is no Folder Start token, folders will not be renamed. If Folder Start is the first token, only folders will be renamed. Note that the rename function operates on the current file selection. However, if folders are renamed, all open files in the renamed folder will have their paths adjusted. When the Folder Start token is encountered all previous If sequences are terminated. Note that IfDup sequences are not permitted after this token.
> Movement Number - Roman
>   Inserts the Movement Number as a Roman numeral.
> Names>Open Filename
>   Inserts the value of the filename when the file was first opened.
> Names>Open Folder
>   Inserts the file's parent folder name when the file was first opened.
> Names>Start Filename
>   Inserts the value of the filename prior to the rename operation.
> Names>Start Folder
>   Inserts the file's parent folder name prior to the rename operation.
> Properties>Bit Depth
>   Inserts the bit depth of the audio stream if meaningful.
> Properties>Bit Rate
>   Inserts the bit rate of the audio stream.
> Properties>File Type
>   Inserts the uppercase file extension.
> Properties>Has Video
>   Inserts the value of the Has Video property. In order that the token can be used to test for existence, the value returned is 1 for True and empty for False.
> Properties>iTunes PID
>   Inserts the value of the iTunes PID property (not a potentially saved iTunes PID UDTI).
> Properties>Stream
>   Inserts the audio stream format.
> Season>Season Pad2
>   Inserts the contents of the Season field, padded if necessary, with a leading zero so that the field occupies two characters.
> Track>Track Pad2
>   Inserts the contents of the Track field, padded if necessary, with a leading zero so that the field occupies two characters.
> Track>Track Pad3
>   Inserts the contents of the Track field, padded if necessary, with up to two leading zeros so that the field occupies three characters.
> Track>Track Pad4
>   Inserts the contents of the Track field, padded if necessary, with up to three leading zeros so that the field occupies four characters.
> Track>Track Smart Pad
>   Inserts the contents of the Track field, padded if necessary, with leading zeros so that the width is consistent for the maximum number of tracks. The Track Count determines the maximum number of tracks.
> Truncate
>   Truncates the current representation to the number of characters specified in the following integer.
>   eg. truncate the result to twenty characters.
>   ❨Truncate❩20❨Break❩
>   See Filename Lengths for special semantics used when the length field is negative.
> Variable>Variable 0 - Variable 9
>   These fields insert the contents of the associated user variable field.