MeidokonWiki:

A rename script, it's mostly the stock one with some tweaks.

// Anime title
set('atitle', at('x-jat'))
if(length(atitle)=0, set('atitle', at('en')))
if(length(atitle)=0, set('atitle', A.Name))
set('atitle', replace(atitle, '\', ' '))

// Special workaround, OreImo S2 is just OreImo. (with a . at the end)
// The filesystem doesn't like this and the dot disappears, meaning S1 gets put in the same directory as S1.
// Just for this special case, rename OreImo. to OreImo S2
if(atitle='Ore no Imouto ga Konna ni Kawaii Wake ga Nai.', set('atitle', 'Ore no Imouto ga Konna ni Kawaii Wake ga Nai S2'))

// Episode title
set('etitle', et('en'))
if(length(etitle)=0, set('etitle', et('x-jat')))
if(length(etitle)=0, set('etitle', et('ja')))
if(length(etitle)=0, set('etitle', E.Name))
set('etitle', replace(etitle, '\', ' '))
set('version', if(F.Version>1, 'v'+F.Version, ''))
set('mepno', if(E.TypeId=1, max(A.TotalEpisodeCount, E.EpisodeTypeCount), E.EpisodeTypeCount))
set('epno', padl(E.EpisodeNo, max(2, length(mepno)), '0') + version)
set('epnounversioned', padl(E.EpisodeNo, max(2, length(mepno)), '0'))
if(E.TypeId=2, set('epno', 'S'+epno))
if(E.TypeId=3, set('epno', 'C'+epno))
if(E.TypeId=4, set('epno', 'T'+epno))
if(E.TypeId=5, set('epno', 'P'+epno))
if(E.TypeId=6, set('epno', 'O'+epno))

// Group name
set('groupname', if(G, if(length(G.Shortname)>0, G.Shortname, G.Name), 'no group'))
set('groupname', if(length(groupname)>0, '['+groupname+']'))
set('groupname', replace(groupname, '\', ' '))

// CRC
set('crc', if(H, H.Crc32, F.Crc))
if(length(crc)>0, set('crc', '('+uc(crc)+')'))

// Compose filename
set('filename', limit(limit(limit(atitle, 90) + ' - ' + epno + ' - ' + etitle, 200) + ' ' + groupname, 235) + crc + '.' + F.FileType)

// Prepare for potential subfolders
set('head', '')

// Make subfolder for anime if there's more than 2 files
//if ((A.MylistCurrentEpisodeCount + A.MylistSpecialEpisodeCount) > 2, set('head', limit(atitle, 80)  + '\'))
//if ((A.TotalEpisodeCount+A.SpecialEpisodeCount) > 1, set('head', limit(atitle, 80)  + '\'))
//if ((A.TotalEpisodeCount+A.SpecialEpisodeCount) < 2, set('head', '!OVAs and single files\'))
//if ((A.MylistCurrentEpisodeCount + A.MylistSpecialEpisodeCount) > 1, set('head', limit(atitle, 80)  + '\'))
//if ((A.MylistCurrentEpisodeCount + A.MylistSpecialEpisodeCount) < 2, set('head', '!OVAs and single files\'))

// Actually nah, always have subfolders, the episode counting is too messy
set('head', limit(atitle, 80)  + '\')

// Prepend subfolder
set('filename', head + filename)

// Remove invalid characters
set('filename', replace(filename, '*', ' '))
set('filename', replace(filename, '/', ' '))
set('filename', replace(filename, '?', '_'))
set('filename', replace(filename, ':', ' '))
set('filename', replace(filename, '"', ' '))
set('filename', replace(filename, '<', ' '))
set('filename', replace(filename, '>', ' '))
set('filename', replace(filename, '|', ' '))
set('filename', replace(filename, '`', "'"))
set('filename', replace(filename, '  ', ' '))

filename

MeidokonWiki: furinkan/AnidbAOM (last edited 2022-05-20 05:26:31 by furinkan)