Filename Template: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
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.]]

=== Adding Directories ===

In addition to altering the name of each individual file on disk, the Filename Template can be used to add ''directories'' to an existing directory structure. For most operations, you will use the [[Directories Template]] to create a folder structure on disk. However, if you want to add a directory "on top of" the existing directory structure, you can do this from within the Filename Template instead.

To do so, simply add the path separator slash appropriate for your OS to the Rule you selected. For example, to add a [Disc #] folder to an existing directory structure, you could select the files, and add this to the beginning of your regular file naming Rule:
* Windows: <tt>if(isempty([Disc #],1),,Disc [Disc #])\</tt>
* Mac and Linux: <tt>if(isempty([Disc #],1),,Disc [Disc #])/</tt>

If you want to pass through the existing file names, and only add the new directory (when required), you could use:
* Windows: <tt>if(isempty([Disc #],1),,Disc [Disc #])\[Filename (Name)]</tt>
* Mac and Linux: <tt>if(isempty([Disc #],1),,Disc [Disc #])/[Filename (Name)]</tt>

For more information on why the above examples use the if(isempty) expression instead of the [Disc #] field directly, refer to the [[Rename,_Move,_and_Copy_Files#Empty_Fields|Empty Fields section]] of the Rename, Move, and Copy Files article.


== Examples ==
== Examples ==

Revision as of 19:35, 5 September 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.

Adding Directories

In addition to altering the name of each individual file on disk, the Filename Template can be used to add directories to an existing directory structure. For most operations, you will use the Directories Template to create a folder structure on disk. However, if you want to add a directory "on top of" the existing directory structure, you can do this from within the Filename Template instead.

To do so, simply add the path separator slash appropriate for your OS to the Rule you selected. For example, to add a [Disc #] folder to an existing directory structure, you could select the files, and add this to the beginning of your regular file naming Rule:

  • Windows: if(isempty([Disc #],1),,Disc [Disc #])\
  • Mac and Linux: if(isempty([Disc #],1),,Disc [Disc #])/

If you want to pass through the existing file names, and only add the new directory (when required), you could use:

  • Windows: if(isempty([Disc #],1),,Disc [Disc #])\[Filename (Name)]
  • Mac and Linux: if(isempty([Disc #],1),,Disc [Disc #])/[Filename (Name)]

For more information on why the above examples use the if(isempty) expression instead of the [Disc #] field directly, refer to the Empty Fields section of the Rename, Move, and Copy Files article.

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 whitespace or zeros. However, as you can see from the results above, the output from [Track #] is padded to two digits with a leading zero. MC always pads many commonly used fields (such as [Track #] and [Episode], among others) 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.

Renaming Movies

Another common issue is naming Movies. For many movies, it is convenient to include the [Year] field in the filename, to distinguish between different versions of the same title. You may also have a few files, perhaps ripped from DVD long ago, which are split into multiple discs. But, you don't want all of your movie filenames to include d00 or some other generic identifier, and you might not want to include the year for movies that don't have good metadata in that field.

This is also solved with a little expression magic:

[Name]If(IsEmpty([Disc #],1),,-[Disc #]) If(IsEmpty([Year],1),,([Year]))

Which outputs as:

A fancy Movie Filename Template example.