AniDB O'Matic - Documentation: Local file renaming: Difference between revisions

From AniDB
Jump to navigation Jump to search
Line 105: Line 105:
===M / MYLIST===
===M / MYLIST===
{|
{|
|?a||text||Anime name
|-
|?ab||number||Audio bitrate
|-
|?ac||text||Audio codec
|-
|?aid||number||Anime ID
|-
|?ar||number||Average review score
|-
|?atv||number||Average temp vote
|-
|?av||number||Average vote
|-
|?e||text||Episode name
|-
|?eid||number||Episode ID
|-
|?ep||text||Episode number, zero padded to match the total number of episodes
|-
|?ep2, ?ep3, ?ep4||text||Zero padded episode number, eg ?ep3 = 007
|-
|?epc||number||Total number of episodes in the current category (for example: 24 for normal episodes, 7 for specials, 2 for op, etc.)
|-
|?epp||number||Movie part number ep1 = 1, ep2 = 1, ep3 = 2, ep4 = 1 etc.
|-
|?epps||number||Total number of movie parts ep1 = 1, ep2 = 2, ep4 = 3
|-
|?eps||number||Total number of episodes
|-
|?fid||number||File ID
|-
|?fs||text||File source
|-
|?g||text||Group name, long (?lg) if available, otherwise short (?sg)
|-
|?gid||number||Group ID
|-
|?isKnown||boolean||True if the file is known to AniDB
|-
|?isMovie||boolean||True if the current file belongs to a movie anime
|-
|?isSpecial||boolean||True if the current file belongs to a special episode (Such as Op or Ed)
|-
|?lang||text||Shows 1-2 Audio and 1-2 Subtitle languages
|-
|?la||text||Shows all audio languages
|-
|?lac||number||Number of audio languages
|-
|?la1, ?la2, ?la3, ?la4||text||Shows 1-4 audio languages
|-
|?lg||text||Long group name
|-
|?ls||text||Shows all subtitle languages
|-
|?lsc||number||Number of subtitle languages
|-
|?ls1, ?ls2, ?ls3, ?ls4||text||Shows 1-4 subtitle languages
|-
|?m||number||Release month of anime
|-
|?me||number||End month of anime
|-
|?mid||number||MyList ID
|-
|?seps||number||Total number of special episodes
|-
|?sg||text||Short group name
|-
|?v||number||File version
|-
|?vb||number||Video bitrate
|-
|?w||boolean||File watched status, true if watched
|-
|?wa||boolean||Anime watched status, true if all normal episodes have been watched
|-
|?wad||text||Anime detailed watched status, returns "none", "partial" or "all"
|-
|?wltg||boolean||True if the anime is marked as "to get" in the wishlist
|-
|?wlp||number||Returns wishlist priority, 0 = high, 1 = normal, 2 = low
|-
|?wltw||boolean||True if the anime is marked as "to watch" in the wishlist
|-
|?y||number||Release year of anime
|-
|?ye||number||End year of anime
|-
|?ym||text||Release year and month of anime
|-
|?yme||text||End year and month of anime
|}
|}
Note that all tags are greedy, that means that ?ep2 will always be read as ep2, never as ?e or ?ep. If you need a tag to not be greedy you can use ?out(ep).


===Function tags===
===Function tags===

Revision as of 00:27, 20 May 2011

File renaming patterns

AoM contains a comprehensive number of patterns to fully customize file names and paths. In order for the pattern to allow very complex rules it essentially allows light scripting. The path can be a complete path or a partial path, in case of a partial path the current file manager is used to place the file based on a known root or from the root folder of the file manager, see file managers below for more details. File extensions are automatically added to the end of the pattern.

Here's a few sample patterns:

  • "?a - ?ep - ?e [?g]" ->
    "Anime - 02 - Episode name [Group name]"
  • "?a - ?epv?v - ?e?if(lg<>'', ' ['+lg+']', '')" ->
    With group: "Anime - 02v1 - Episode name [Group name]"
    Without group:"Anime - 02v1 - Episode name"
  • "?if(wltw, 'To watch\', '')?a?if(isMovie, if(epps>1, ' - Part '+epp+if(v>1, 'v'+v, ''), if(v>1, ' - v'+v, '')), ep+if(v>1, v, '')+'- ?e') ?if(lg<>'', lg+' ', ''){?crc32}" ->
    For a movie: "Anime name - v2 [Group name]{crc32}"
    For a movie with 2 parts: "Anime name - Part 2v2 [Group name]{crc32}
    For a normal anime, marked as "to watch in wishlist": "To watch\Anime name - 02v2 - Episode name [Group name]{crc32}

Default pattern

Split into multiple lines for easier viewing. ;)

?set('V', if(v>1, 'v'+v, ''))
?set('A', a)
?set('E', if(isMovie and (eps=1), if(epps>1, if(length(V)>0, V+' - ', '')+'Part '+epp, if(length(V)>0, V, '')), if(eps>1, ep+V+' - '+e, if(length(V)>0, V+' - '+e, e))))
?set('LANG', la2+if((length(la2)>0) and (length(ls2)>0), '-')+ls2)
?set('LANG', if(length(LANG)>0, '('+LANG+')'))
?set('G', if(gid>0, g, if((lac<=1) and (lsc=0) and ((la='ja') or (la='')), '[RAW]')))
?set('CRC', if(length(crc)>0, '{'+crc+'}', ''))
?set('TAIL', join(' ', LANG, G, CRC))
?set('TAIL', if(length(TAIL)>0, ' '+TAIL))
?set('TOTLEN', length(A)+length(E)+length(TAIL))
?if(TOTLEN>240, if(length(E)>50, set(E, limit(E, max(50, 240-length(A)-length(TAIL))))))
?set('TOTLEN', length(A)+length(E)+length(TAIL))
?if(TOTLEN>240, if(length(A)>50, set(A, limit(A, max(50, 240-length(E)-length(TAIL))))))
?out(A+if(length(E)>0, ' - '+E)+TAIL)

The end result is all lines merged with the line feeds removed.

Constant expressions

There are two ways to specify string literals:
'text' - use '' to insert a ' (e.g. 'her''s')
or
"text" - use \" to insert a " (e.g. "a \"quotation\"")

Number literals are simply written as numbers:
1234

There are also boolean constants:
true
false

Objects

A / ANIME

AnimeNFOId integer
AnimeNFOStr string
Category integer
Date integer
Description widestring
Name widestring
PictureUrl string
Producer widestring
ReviewAverage integer
ReviewCount integer
TotalEpisodeCount integer
Updated integer
Url string
VoteAverage integer
VoteCount integer
Year string
EpisodeCount integer
GenreCount integer
GenreString widestring
SpecialEpisodeCount integer
CategoryStr widestring
DownloadState TAniDBAnimeDownloadState
WatchedState TAniDBAnimeWatchedState
StatusState TAniDBAnimeStatusState
StartYear integer

E / EPISODE

F / FILE

G / GROUP

H / HASH

M / MYLIST

Function tags

contains(find, text) boolean Returns true if find is found in text.
Example: contains('bcd', 'abcdef') = true
if(test, trueval[, falseval]) any If statement, returns trueval if test is true, otherwise returns falseval.
Example: if(23=23, 'equal', 'not equal') = 'equal'
in(find, text...) boolean Checks if find is present in a number of text parameters.
Example: in('bb', 'aa', 'bb', 'cc', 'dd') = true
join(glue, text...) text Joins together two or more texts, empty parameters are ignored with no glue added.
Example: join(' ', 'a', 'b', 'c') = 'a b c'
lc(text) text Converts text to lower case.
Example: lc('ABCDEF') = 'abcdef'
length(text) number Returns the length of text.
Example: length('abcdef') = 6
limit(text, length[, end]) text Limits the length of text to at most length characters. End is optional, if specified and the text is cropped, it'll be added at the end of text.
Example: limit(e, 100) or limit('abcdefghijklmnop', 7, '...') = 'abcd...'
min(number...) number Returns the lowest supplied number
Example: min(1, 7, 3, 9, 2) = 1
max(number...) number Returns the highest supplied number
Example: max(1, 7, 3, 9, 2) = 9
pad(text) text Converts text to sentence case.
Example ?sc(a)
padl(text) text Converts text to sentence case.
Example ?sc(a)
padr(text) text Converts text to sentence case.
Example ?sc(a)
sc(text) text Converts text to sentence case.
Example: sc('HELLO THERE!') = 'Hello there!'
set(name, data) nothing Declares a new variable called name containing data.
Example: set('temp', 'text')
split(text, find, index) text Splits text on find and returns the specified index. Index starts from 1.
Example: split('2011-05-19', '-', 2) = 05
start(text, find) boolean Checks if find matches the start of text.
Example: start('1999', '199') = true
tc(text) text Converts text to title case.
Example: tc('HELLO THERE!') = 'Hello There!'
uc(text) text Converts text to upper case.
Example: uc('abcd') = 'ABCD'

Arithmetic operators

A+B returns A plus B
A-B returns A minus B
A*B returns A multiplied B
A/B returns A divided by B

Comparison operators

A=B true if A equals B
A<>B true if A does not equal B
A<B true if A is less than B
A>B true if A is more than B
A<=B true if A is less or equal to B
A>=B true if A is more or equal to B

Logical operators

A and B true if both A and B are true
A or B true if either A or B is true
A xor B true if either A or B is true but not both
not A true if A is false

File managers

File managers are used to automatically manage file renaming / removing and adding / updating files in your MyList.

Source paths

Each file manager can have multiple source folders. File managers can be set to search these folders recursively or only the folder itself for files. While it's possible adding a source path to multiple file managers is strongly discouraged.

Rename pattern

Each file manager can have 1 renaming pattern. To use multiple patterns you need to specify multiple patterns. The rename pattern can contain a part of a path or a full path to indicate where the file should be stored. The path part of a rename might be ignored under certain circumstances however, see below.

Target paths

A file manager can have one or more target paths for moving files. If no target path is specified the folder the file was found in will be used instead. If there are multiple target paths the file manager will try to figure out where the file has the most related files. This is determined by a) the anime the file belongs to and b) the anime group the file belongs to. If there's not enough space available on the target drive it'll check the next preferred target if there's enough space and so on. If no space is available in any target path the file will be renamed in it's current location, but with any path part of the file removed, aka the filename part of the rename pattern will be used but the file will remain in the folder it was found in.

Only move known files

This will make the file manager ignore files which are not in AniDB, they'll be visible on the known files page, but they will never be moved or renamed.

Automatically remove deleted files

This will make the file manager remove files it can't find any more from the known files page. This rule ignores files stored on removable media.

Don't remove files if the volume can't be found

This will prevent the file manager from removing files it can't find when the whole volume is gone, this rule would for example prevent your known files from being cleared if your network cable is unplugged or a HDD is disconnected.

Add new files to AniDB

This will make the file manager automatically add found files to your MyList.

Automatically update the storage field of MyList entries

This will make the file manager automatically update the storage field of MyList entries based on the volume it's stored on. This field currently only works for files on a removable storage such as a DVD. The label used will be the label of the removable media, e.g. DVD #013.

Automatically mark found files as OnHDD or OnRemovable in MyList

This will make the file manager update your MyList to OnHDD if the file was found on a HDD or Network drive, or OnRemovable if the file is on a CD/DVD.

Automatically mark removed files as Deleted in MyList

This will make the file manager update your MyList to indicate the file has been deleted if removed by the above rule.