Filename Template: Difference between revisions
Line 52: | Line 52: | ||
: <tt>If(IsEmpty([Season],1),,s[Season])If(IsEmpty([Episode],1),e00,e[Episode]) - [Name]</tt> |
: <tt>If(IsEmpty([Season],1),,s[Season])If(IsEmpty([Episode],1),e00,e[Episode]) - [Name]</tt> |
||
Which outputs this when the |
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.]] |
[[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: |
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.]] |
[[File:RMCF-Filename-TV Episode Advanced.png|thumb|none|720px|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: |
|||
: <tt>[Name]If(IsEmpty([Disc #],1),,-[Disc #]) If(IsEmpty([Year],1),,([Year]))</tt> |
|||
Which outputs as: |
|||
[[File:RMCF-Filename-Movie.png|thumb|none|720px|A fancy Movie Filename Template example.]] |
|||
[[Category:Rename, Move, and Copy Files]] |
[[Category:Rename, Move, and Copy Files]] |
Revision as of 06:16, 31 May 2015
- See also: Rename, Move, and Copy 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.
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:
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 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]
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:
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:
But which matches the output from the simpler rule above for your other shows:
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: