User:Worf/AOM Renaming Rules

From AniDB
< User:Worf
Revision as of 23:08, 3 August 2022 by Worf (talk | contribs) (Created page with "function('animename', _ set('atitle', '') + _ set('atitle', A.Name) + _ if(start(atitle, '.'), set('atitle', copy(atitle, 2, length(atitle)))) + _ set('atitle', replacei(atitle, ': ', ' - ')) + _ set('atitle', replacei(atitle, '1/2', '½')) + _ set('atitle', replacei(atitle, '*', ' ')) + _ set('atitle', replacei(atitle, '/', '-')) + _ set('atitle', replacei(atitle, '?', ' ')) + _ set('atitle', replacei(atitle, '"', ' ')) + _ set('atitle', replacei(atitle, '<',...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

function('animename', _ set('atitle', ) + _ set('atitle', A.Name) + _ if(start(atitle, '.'), set('atitle', copy(atitle, 2, length(atitle)))) + _ set('atitle', replacei(atitle, ': ', ' - ')) + _ set('atitle', replacei(atitle, '1/2', '½')) + _ set('atitle', replacei(atitle, '*', ' ')) + _ set('atitle', replacei(atitle, '/', '-')) + _ set('atitle', replacei(atitle, '?', ' ')) + _ set('atitle', replacei(atitle, '"', ' ')) + _ set('atitle', replacei(atitle, '<', '-')) + _ set('atitle', replacei(atitle, '>', '-')) + _ set('atitle', replacei(atitle, '>', '-')) + _ set('atitle', replacei(atitle, '<', '-')) + _ set('atitle', replacei(atitle, '|', ' ')) + _ set('atitle', replacei(atitle, ':', ' ')) + _ set('atitle', replacerepeat(atitle, ' ', ' ')) + _ if(start(atitle, ' '), set('atitle', copy(atitle, 2, length(atitle)))) + _

atitle _ )

function('animefolder', _ set('afolder', ) + _ set('afolder', A.Name + ' {' + A.id + '}') + _ if(start(afolder, '.'), set('afolder', copy(afolder, 2, length(afolder)))) + _ set('afolder', replacei(afolder, ': ', ' - ')) + _ set('afolder', replacei(afolder, '1/2', '½')) + _ set('afolder', replacei(afolder, '*', ' ')) + _ set('afolder', replacei(afolder, '/', '-')) + _ set('afolder', replacei(afolder, '?', ' ')) + _ set('afolder', replacei(afolder, '"', ' ')) + _ set('afolder', replacei(afolder, '<', '-')) + _ set('afolder', replacei(afolder, '>', '-')) + _ set('afolder', replacei(afolder, '>', '-')) + _ set('afolder', replacei(afolder, '<', '-')) + _ set('afolder', replacei(afolder, '|', ' ')) + _ set('afolder', replacei(afolder, ':', ' ')) + _ set('afolder', replacerepeat(afolder, ' ', ' ')) + _ if(start(afolder, ' '), set('afolder', copy(afolder, 2, length(afolder)))) + _

afolder _ )

function('animetype', _ set('atype', ) + _ if(in(A.Category, 1, 3, 4, 5, 6, 7, 8), set('atype', ' ['+A.CategoryStr+']')) + _ if(A.Restricted, set('atype', ' [Hentai]')) + _

atype _ )

function('animetype2', _ set('atype2', ) + _ if(in(A.Category, 1, 2, 3, 4, 5, 6, 7, 8), set('atype2', A.CategoryStr)) + _ if(A.Restricted, set('atype2', ' [Hentai]')) + _

atype2 _ )

function('episodenumber', + _ set('epno', ) + _ set('version', if(F.Version>1, 'v'+F.Version, )) + _ set('mepno', max(A.TotalEpisodeCount, E.EpisodeCount)) + _ set('prevep', 0) + _ set('tempep', 0) + _ set('epstr', ) + _ if((sameeptype=1 AND count(eplistdetails, ',')>0), + _ for('counter', 1, count(eplistdetails, ',')+1, + _ set('curep', strtoint(split(F.EpisodeList, ',', counter))) + _ if(A.id=69 OR A.id=266, set('curepstr', padl(curep, max(4, length(mepno)), '0')), set('curepstr', padl(curep, max(3, length(mepno)), '0'))) + _ if(A.id=69 OR A.id=266, set('prevepstr', padl(prevep, max(4, length(mepno)), '0')), set('prevepstr', padl(prevep, max(3, length(mepno)), '0'))) + _

if(prevep=0, set('epstr', curepstr)) + _ if(prevep<>0 AND curep=(prevep+1), set('tempep', curep)) + _ if(prevep<>0 AND curep>(prevep+1) AND tempep<>0, set('epstr', epstr + '-' + prevepstr) + set('tempep', 0)) + _ if(prevep<>0 AND curep>(prevep+1), set('epstr', epstr + '+' + curepstr)) + _ if(prevep<>0 AND curep=(prevep+1) AND tempep<>0 AND counter=count(eplistdetails, ',')+1, set('epstr', epstr + '-' + curepstr)) + _ if(prevep<>0 AND curep>(prevep+1) AND tempep<>0 AND counter=count(eplistdetails, ',')+1, set('epstr', epstr + '+' + curepstr)) + _

set('prevep', curep) _ ) + set('epno', epstr + version), + _ if(A.id=69 OR A.id=266, set('epno', padl(E.EpisodeNo, max(4, length(mepno)), '0') + version), set('epno', padl(E.EpisodeNo, max(3, length(mepno)), '0') + version)) _ ), _

epno _ )

function('episodename', + _ set('filecoverage', ) + _ set('eplistdetails', F.EpisodeListDetails) + _ set('sameeptype', 0) + _ if(A.Category<>4 AND NOT contains(',', eplistdetails) AND F.EpisodePercent='0-100', set('filecoverage', 'complete episode') + set('sameeptype', 1)) + _ if(A.Category<>4 AND NOT contains(',', eplistdetails) AND F.EpisodePercent<>'0-100', set('filecoverage', 'partial episode') + set('sameeptype', 1)) + _

if(contains(',', eplistdetails), + _ set('eparts', count(eplistdetails, ',')+1) + _ set('firsteptype', split(split(eplistdetails, ',', 1), ':', 2)) + _ set('firstepanime', split(split(eplistdetails, ',', 1), ':', 3)) + _ set('sameeptype', 1) + _ for('counter', 1, eparts, + _ if(split(split(eplistdetails, ',', counter), ':', 2)<>firsteptype, set('sameeptype', 0)) + _ if(split(split(eplistdetails, ',', counter), ':', 3)<>firstepanime, set('sameeptype', 0)) + _ if(split(split(eplistdetails, ',', counter), ':', 5)<>0, set('sameeptype', 0)) + _ if(split(split(eplistdetails, ',', counter), ':', 6)<>100, set('sameeptype', 0)) _ ) + _ if(sameeptype=1, set('filecoverage', 'multiple episodes same type same anime')) _ ) + _

set('epno', episodenumber(A, E, sameeptype)), _

set('epn', ), _ if(E.TypeId=1, set('epn', ' (Episode '+epno+')')), _ if(E.TypeId=2, set('epn', ' (Special '+epno+')')), _ if(E.TypeId=3, set('epn', ' (Credits '+epno+')')), _ if(E.TypeId=4, set('epn', ' (Trailer '+epno+')')), _ if(E.TypeId=5, set('epn', ' (Parody '+epno+')')), _ if(E.TypeId=6, set('epn', ' (Other '+epno+')')), _

set('epm', ), _ if(A.Category=4, set('epm', ' (Movie '+epno+')')), _ if(A.Category=4 AND E.TypeId=1, set('epm', ' (Movie '+epno+')')), _ if(A.Category=4 AND A.TotalEpisodeCount=1 AND E.EpisodeNo>1 AND E.TypeId=1, set('epm', ' (Movie 001)')), _ if(A.Category=4 AND in(E.TypeID, 2, 3, 4, 5, 6), set('epm', epm+epn)), _

set('ep', ), _ set('ep', if(A.Category=4, epm, epn)), _

set('eplus', ), _ set('etitle', et('en')), _ if(length(etitle)=0, set('etitle', et('x-jat'))), _ if(length(etitle)=0, set('etitle', et('ja'))), _

if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent<>'0-100' AND contains('Part', split(F.Other, '
', 1)), set('eplus', eplus+' ('+split(F.Other, '
', 1)+')')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='0-50', set('eplus', ' (Part 1 of 2)')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='50-100', set('eplus', ' (Part 2 of 2)')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='0-33', set('eplus', ' (Part 1 of 3)')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='33-67', set('eplus', ' (Part 2 of 3)')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='67-100', set('eplus', ' (Part 3 of 3)')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='0-25', set('eplus', ' (Part 1 of 4)')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='25-50', set('eplus', ' (Part 2 of 4)')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='50-75', set('eplus', ' (Part 3 of 4)')), _ if(A.CATEGORY<>4 AND NOT contains(',', F.EpisodeListDetails) AND F.EpisodePercent='75-100', set('eplus', ' (Part 4 of 4)')), _ if(A.Category=4 AND A.TotalEpisodeCount>1 AND E.TypeId=1, set('eplus', eplus+' ('+etitle+')')), _ if(A.Category=4 AND A.TotalEpisodeCount=1 AND E.EpisodeNo>1 AND E.TypeId=1 AND contains('Part ', et('en')), set('eplus', eplus+' ('+etitle+')')), _ if(in(E.TypeID, 2, 3, 4, 5, 6), set('eplus', ' ('+etitle+')')), _ if(E.TypeId=3 AND contains('Creditless', split(F.Other, '
', 1)), set('eplus', eplus+' ('+split(F.Other, '
', 1)+')')), _

ep + eplus _ )

for('i', 1, 99, if(length(split(PATH, '\', i)) >0, set('origfilename', split(PATH, '\', i))))

set('head', copy(animename(A), 1, 1)) if(numeric(head), set('head', '0-9'))

set('crc', if(H, H.Crc32, F.Crc)) if(length(crc)>0, set('crc', ' ['+uc(crc)+']')) set('group', if(G, if(length(G.Shortname)>0, G.Shortname, G.Name))) set('group', if(length(group)>0, ' ['+group+']')) set('groupname', if(G, if(length(G.Name)>0, '['+G.Name+']'), 'no group')) set('censored', ) set('tversion', F.Version) set('state_map', F.State mod 4096) if(state_map>=2048, set('tversion', 9) + set('state_map', state_map - 2048)) if(state_map>=1024, if(tversion<9, set('tversion', 8)) + set('state_map', state_map - 1024)) if(state_map>=512, if(tversion<9, set('tversion', 7)) + set('state_map', state_map - 512)) if(state_map>=256, if(tversion<9, set('tversion', 6)) + set('state_map', state_map - 256)) if(state_map>=128, set('censored', 'yes') + set('state_map', state_map - 128)) if(state_map>=64, set('censored', 'no') + set('state_map', state_map - 64)) set('tversion', if(tversion>1, 'v'+F.Version, )) set('censored', if(F, if(A.Restricted, if(censored='yes', ' (cen)', if(censored='no', ' (unc)', )))))


set('ext', '.'+F.FileType)

set('filename', animename(A) + animetype(A) + episodename(A, E) + crc + group + censored + ext)


if(start(PATH, 'F:\Anime (DDD)\'), set('filename', animename(A) + animetype(A) + episodename(A, E) + crc + group + censored + ' {anidb}' + ext)) if(start(PATH, 'Q:\'), set('filename', 'matched files\'+uc(F.FileType)+'\' + animename(A) + animetype(A) + episodename(A, E) + crc + group + censored + ' {anidb}' + ext)) if(start(PATH, 'Z:\'), set('filename', uc(F.FileType)+'\' + animename(A) + animetype(A) + episodename(A, E) + crc + group + ' {anidb}' + ext)) if(start(PATH, 'U:\'), set('filename', animename(A) + animetype(A) + '\' + filename)) if(start(PATH, 'V:\'), set('filename', animename(A) + animetype(A) + '\' + filename)) if(start(PATH, 'W:\'), set('filename', animename(A) + animetype(A) + '\' + filename)) if(start(PATH, 'X:\'), set('filename', animename(A) + animetype(A) + '\' + filename))

set('filename', replacei(filename, '*', ' ')) set('filename', replacei(filename, '/', ' ')) set('filename', replacei(filename, '?', ' ')) set('filename', replacei(filename, ': ', ' - ')) set('filename', replacei(filename, ':', ' ')) set('filename', replacei(filename, '"', "'")) set('filename', replacei(filename, '<', ' ')) set('filename', replacei(filename, '>', ' ')) set('filename', replacei(filename, '>', '-')) set('filename', replacei(filename, '<', '-')) set('filename', replacei(filename, '|', ' ')) set('filename', replacerepeat(filename, ' ', ' '))


if(start(PATH, 'F:\Anime (DDD)\'), set('filename', 'F:\Anime (DDD)\sorted\' + filename)) if(start(PATH, 'Q:\'), set('filename', 'Q:\' + filename)) if(start(PATH, 'U:\'), set('filename', 'U:\' + filename)) if(start(PATH, 'V:\'), set('filename', 'V:\' + filename)) if(start(PATH, 'W:\'), set('filename', 'W:\' + filename)) if(start(PATH, 'X:\'), set('filename', 'X:\' + filename))

if(start(PATH, 'M:\#to_sort'), set('filename', 'M:\' + animetype2(A) + '\' + animefolder(A) + '\' + filename)) if(start(PATH, 'P:\#to_sort'), set('filename', 'P:\' + animetype2(A) + '\' + animefolder(A) + '\' + filename)) if(start(PATH, 'S:\#to_sort'), set('filename', 'S:\' + animetype2(A) + '\' + animefolder(A) + '\' + filename)) if(start(PATH, 'T:\#to_sort'), set('filename', 'T:\' + animetype2(A) + '\' + animefolder(A) + '\' + filename))

filename