Filename Template: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
No edit summary
No edit summary
Line 16: Line 16:


[[File:RMCF-Filename-Disclosure Button-Win.png|thumb|420px|none|The disclosure button in the Filename Template box on Windows.]]
[[File:RMCF-Filename-Disclosure Button-Win.png|thumb|420px|none|The disclosure button in the Filename Template box on Windows.]]

== Examples ==

To use the Filename Template, you often simply insert the Fields you want included in the filename portion of the destination file path, with a few separator characters, and that's it. The easiest way to understand how to use the Filename Template is with examples.

=== Simple Music Track Rule ===

Starting with a simple example, say you want a very basic filename scheme for your music files consisting of just the [Track #] and [Name] fields, separated by a dash. You don't need to include [Artist] and [Album] because they're already included in the filesystem through your [[Directories Template]]. This is simple, use the following rule:
: <tt>[Track #] - [Name]</tt>

If you apply that to the album ''Arrival'' by ABBA, you'll get:
[[File:RMCF-Filename-ABBA Example.png|thumb|none|720px|Renaming some ABBA, because we had to include ABBA as an example.]]

Very simple.

However, it is worth noting something about how Media Center handles number fields. For most fields, the output is "trimmed" to not include any leading zeros. However, the Rename, Move, and Copy Files tool handles a few commonly used number fields specially, including [Track #]. As you can see from the results above, the output from [Track #] is padded to two digits with a leading zero. MC always pads a few commonly used fields ([Track #] and [Episode], for example) to a minimum of two digits.

If you want to override this behavior, you can specify your own padding with the [[Expression_Language#PadNumber.28.E2.80.A6.29:_Adds_leading_zeros_to_any_given_number|PadNumber() function]]. So, if you wanted it to use three digits instead, you could use:
: <tt>PadNumber([Track #],3) - [Name]</tt>

[[File:RMCF-Filename-ABBA Example Padded.png|thumb|none|720px|ABBA with ''all'' the Track Number digits.]]

=== Renaming TV Episodes ===

Another common usage might be renaming TV episodes you've recorded. For these, a good idea is to use a common Series and Episode notation in the file name, which will be automatically recognized by [[Carnac]] should you ever lose metadata in your Library about the episodes for some reason. A common example of this is something like:
: <tt>M:\Video\TV Show\The Walking Dead\05\s05e11 - The Distance.mkv</tt>

This might seem difficult to achieve, but it is actually quite simple. Remember the rule: All text entered that does not match a valid Library Field or Expression Language function will be passed through verbatim. Whitespace can be included around your "separators" (as was done with the dash in the Music example above), but it does not need to be. So, a simple example that will generate a filename like the one above is:
: <tt>s[Season]e[Episode] - [Name]</tt>

That's all it takes:
[[File:RMCF-Filename-TV Episode Simple.png|thumb|none|720px|A simple rule to apply sNNeNN style episode numbering.]]

This works for most types of shows, but it can be troublesome if you have a few shows that don't really have seasons (miniseries episodes, for example). You'd typically want these to simply be numbered by episode, and to omit the Season part (which may be set to zero or empty). Here's a slightly fancier version of the same thing, which omits the sNN part of the name when it isn't needed, by using a few simple If(IsEmpty) style expressions:
: <tt>If(IsEmpty([Season],1),,s[Season])If(IsEmpty([Episode],1),e00,e[Episode]) - [Name]</tt>

Which outputs this when the [[Series]] field is blank:
[[File:RMCF-Filename-TV Episode-Blank Series.png|thumb|none|720px|A fancier rule to handle shows with no [Series] field values.]]

But which matches the output from the simpler rule above for your other shows:
[[File:RMCF-Filename-TV Episode Advanced.png|thumb|none|720px|The fancier rule still works with regular shows too.]]


[[Category:Rename, Move, and Copy Files]]
[[Category:Rename, Move, and Copy Files]]

Revision as of 05:58, 31 May 2015

The Filename Template with a basic setup for music files.

The Filename Template is used to set the naming of the files selected in the tool. Like the Directories Template, it consists of a Rule which auto-generates the filename base on each file's metadata. The Filename Template does not consider the source filenames at all, and the replacement name is built from scratch using the Rule.

For example, you might want to name your music files with their [Disc #], [Track #], and [Name], and your movies with their [Name] and [Year].

Use

The Filename Template consists of only a single Rule, which is constructed using the following system:

  • If the Filename Template is not enabled, the files' existing filenames will be passed through untouched.
  • Insert file-specific properties by using the standard Library Field square bracket notation, such as [Track #], [Episode], [Year], or [Name].
  • The rule may also contain Expression Language functions.
  • All text entered that does not match a valid Library Field or Expression Language function will be passed through verbatim.
  • The disclosure button in the Rule text box shows a pop-out menu that shows recently-used templates, a few presets, allows you to insert Expression Language functions, and other handy tools.
The disclosure button in the Filename Template box on Windows.

Examples

To use the Filename Template, you often simply insert the Fields you want included in the filename portion of the destination file path, with a few separator characters, and that's it. The easiest way to understand how to use the Filename Template is with examples.

Simple Music Track Rule

Starting with a simple example, say you want a very basic filename scheme for your music files consisting of just the [Track #] and [Name] fields, separated by a dash. You don't need to include [Artist] and [Album] because they're already included in the filesystem through your Directories Template. This is simple, use the following rule:

[Track #] - [Name]

If you apply that to the album Arrival by ABBA, you'll get:

Renaming some ABBA, because we had to include ABBA as an example.

Very simple.

However, it is worth noting something about how Media Center handles number fields. For most fields, the output is "trimmed" to not include any leading zeros. However, the Rename, Move, and Copy Files tool handles a few commonly used number fields specially, including [Track #]. As you can see from the results above, the output from [Track #] is padded to two digits with a leading zero. MC always pads a few commonly used fields ([Track #] and [Episode], for example) to a minimum of two digits.

If you want to override this behavior, you can specify your own padding with the PadNumber() function. So, if you wanted it to use three digits instead, you could use:

PadNumber([Track #],3) - [Name]
ABBA with all the Track Number digits.

Renaming TV Episodes

Another common usage might be renaming TV episodes you've recorded. For these, a good idea is to use a common Series and Episode notation in the file name, which will be automatically recognized by Carnac should you ever lose metadata in your Library about the episodes for some reason. A common example of this is something like:

M:\Video\TV Show\The Walking Dead\05\s05e11 - The Distance.mkv

This might seem difficult to achieve, but it is actually quite simple. Remember the rule: All text entered that does not match a valid Library Field or Expression Language function will be passed through verbatim. Whitespace can be included around your "separators" (as was done with the dash in the Music example above), but it does not need to be. So, a simple example that will generate a filename like the one above is:

s[Season]e[Episode] - [Name]

That's all it takes:

A simple rule to apply sNNeNN style episode numbering.

This works for most types of shows, but it can be troublesome if you have a few shows that don't really have seasons (miniseries episodes, for example). You'd typically want these to simply be numbered by episode, and to omit the Season part (which may be set to zero or empty). Here's a slightly fancier version of the same thing, which omits the sNN part of the name when it isn't needed, by using a few simple If(IsEmpty) style expressions:

If(IsEmpty([Season],1),,s[Season])If(IsEmpty([Episode],1),e00,e[Episode]) - [Name]

Which outputs this when the Series field is blank:

A fancier rule to handle shows with no [Series] field values.

But which matches the output from the simpler rule above for your other shows:

The fancier rule still works with regular shows too.