Renamer Plugin for Shoko
If 'findLastLocation' is used, the last added file's location from the same anime will be used if it exists.
The only destination folders settable by the renamer are import folders with Drop Type of Destination or Both.
The final destination MUST match the name or absolute path of a drop folder in order to move the file.
If using name to set, destination import folder name must be unique or moving file will fail.
Destination defaults to the first destination folder it can find.
Subfolder defaults to your preferred language anime title.
if (GroupShort)
add '[' GroupShort '] ';
else if (GroupLong)
add '[' GroupLong '] ';
if (AnimeTitleEnglish)
add AnimeTitleEnglish ' ';
else
add AnimeTitle ' ';
// Only adds episode numbers and titles if it is an episode or movie with parts
if (not (AnimeType is Movie and EpisodeTitleEnglish contains 'Complete Movie')) {
add EpisodeNumbers pad 10;
if (Version > 1)
add 'v' Version;
add ' ';
// Don't bother with episode names if there are multiple file relations or if it doesn't have a name (these start with Episode xx)
if (not MultiLinked and EpisodeTitleEnglish and not EpisodeTitleEnglish contains 'Episode') {
// Episode names can get LONG, so truncate them
add trunc(EpisodeTitleEnglish, 35);
if (len(EpisodeTitleEnglish) > 35)
add '...';
add ' ';
}
}
add '(' Resolution ' ' VideoCodecShort ' ';
if (BitDepth and BitDepth != 8)
add BitDepth 'bit';
if (Source)
add ' ' Source;
add ') ';
if (DubLanguages has English)
if (DubLanguages has Japanese)
add '[DUAL-AUDIO] ';
else
add '[DUB] ';
else if (DubLanguages has Japanese and not SubLanguages has English)
add '[RAW] ';
if (Restricted)
if (Censored)
add '[CEN] ';
else
add '[UNC] ';
add '[' CRCUpper ']';
// Truncate filename just in case, old windows max path length is 260 chars
filename set trunc(Filename, 120);
if (SeriesInGroup > 1)
subfolder set GroupName '/' AnimeTitle;
else
subfolder set AnimeTitle;
if (not Sublanguages) filename add '[RAW]';
else {
add 'subs:' Sublanguages;
}
if (AnimeTitles has English and Main)
subfolder set first(AnimeTitles has English and Main);
add EpisodePrefix EpisodeNumber pad MaxEpisodeCount;
if (LastEpisodeNumber != EpisodeNumber)
add '-' LastEpisodeNumber pad MaxEpisodeCount;
filename set trunc(Filename, 120);
// this is a line comment
/* this is a multi-
line comment */
AnimeTitlePreferred or AnimeTitle
AnimeTitleRomaji // Note: these may fall back to synonym titles, use first(AnimeTitles has <Language> and <TitleType>) if you want a specific type
AnimeTitleEnglish //
AnimeTitleJapanese //
EpisodeTitleRomaji // Same as above, use EpisodeTitles collection for specific type
EpisodeTitleEnglish //
EpisodeTitleJapanese //
GroupShort // Release Group short name
GroupLong // Release Group long name
CRCLower
CRCUpper
Source
Resolution // Standardized Resolution, use Height 'x' Width for exact dimensions
AnimeType
EpisodeType
EpisodePrefix
VideoCodecLong // Entire CodecID returned by MediaInfo (or AniDB if no local media info), usually you want the short codec
VideoCodecShort // Simplified video codec
Duration
GroupName // Shoko's Group name
OldFilename // Filename before the renamer script was run
OriginalFilename // Filename stored by AniDB when a file is added to the database
OldImportFolder // Import folder before move **Not available while renaming**
EpisodeNumbers // All episode numbers, as a space-seperated string. e.g. "1-3 5-6 C2 S1-2 S4 P5" Can also use padding like numbers.
Filename // Access currently building filename
Destination // Access currently building destination
Subfolder // Access currently building subfolder
Dates:
AnimeReleaseDate
EpisodeReleaseDate
FileReleaseDate
AnimeID
EpisodeID
EpisodeNumber
Version
Width
Height
EpisodeCount // Number of episodes of this episodes type
BitDepth
AudioChannels
SeriesInGroup // Number of series associated with a Shoko group
LastEpisodeNumber // Same as EpisodeNumber unless file is associated with multiple episodes. Last episode in first contiguous series of episode numbers of the same EpisodeType
MaxEpisodeCount // Max of all episode type counts
Restricted
Censored
Chaptered
ManuallyLinked
InDropSource // True if import folder moving from is a drop source
MultiLinked // If file is linked with multiple episodes
AudioCodecs
DubLanguages
SubLanguages
AnimeTitles
EpisodeTitles
ImportFolders // Available drop folders (marked as destination)
Main
None
Official
Short
Synonym
Episode
Credits
Special
Trailer
Parody
Other
Movie
OVA
TVSeries
TVSpecial
Web
Other
Unknown
English
Romaji
Japanese
(cont ...)
Refer to this grammar for full syntax in EBNF form.
Targets:
can use single wildcard in place of subfolder names to match old subfolder names at same depth.
e.g. old: anime/mystuff/name, new: movies/*/newname, result: movies/mystuff/newname
Control:
Standard code block, enclosing multiple statements, required after if/else statements if using multiple statements
Statements (All end with a semicolon):
Append strings to the end of the current target
Reset the target to the strings
Replace all instances of first string by the second string in the target
Cancel renaming and moving with an exception
Skip renaming or moving, deferring to the next renamer/mover in the priority list
Enables using last added file's location from the same anime
Remove reserved characters instead of replacing them with alternatives
Logging
Collections:
String for AudioCodec and Import Folders (name or absolute path)
Only supported by AnimeTitle and EpisodeTitle, for Types+Language enums
Get first element of a collection
Boolean Expressions (In order of precedence):
Invert the value of the expression
True if collection is non-empty
Used by AnimeType and EpisodeType, checks the type
True if string contains another string as a substring
Only supports integers at this time
Checks equality/inequality
Boolean and expression
Boolean or expression
Expression parentheses for enforcing order of operations
Bools:
True if non-zero
True if non-empty
Numbers:
Length of a collection or a string
Strings:
Comma delimited list, null if empty
Able to pad number up to same number of digits as second number, commonly used with EpisodeCount or MaxEpisodeCount. Special case: works with EpisodeNumbers string
Returns string with old string replaced with new string
Replaces using a Regular Expression, see
hereand
herefor more information.
Matches a string with a pattern and returns the first match
Returns string starting at given index
Returns string starting at given index with given length
Returns string with characters after length sliced off
Trims whitespace on ends of string
Convert to all uppercase
Convert to all lowercase
Convert to title case (each word capitalized)
Dates:
Comments:
Line comment
Block Comment
Requires Antlr4 and Java Runtime to compile
antlr4 quick-start: https://github.com/antlr/antlr4/blob/master/doc/getting-started.md