Rename folders only for HAMA by [anidb-###]

Running FileBot from the console, Groovy scripting, shell scripts, etc
gcs8
Posts: 18
Joined: 06 Apr 2024, 15:17

Re: Rename folders only for HAMA by [anidb-###]

Post by gcs8 »

v2 of AoM renaming to fix some path length issues and yoink out ~

Groovy: Select all

// Anime title
set('atitle', at('en'))
if(length(atitle)=0, set('atitle', at('x-jat')))
if(length(atitle)=0, set('atitle', A.Name))
set('atitle', replace(atitle, '\', ' '))
if(start(atitle, '.'), set('atitle', copy(atitle, 2, length(atitle))))
set('atitle', replace(atitle, '...', ''))
set('atitle', replace(atitle, '1/2', '½'))
set('atitle', trim(atitle))
set('uncensored', (F.State and 64) > 1)
set('censored', (F.State and 128) > 1)

// 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('etitle', replace(etitle, '...', ''))
set('etitle', trim(etitle))

// Version
set('version', if(F.Version>1, 'v'+F.Version, ''))
set('v2n', version)

// Episode number and prefix
set('mepno', if(E.TypeId=1, max(A.TotalEpisodeCount, E.EpisodeTypeCount), E.EpisodeTypeCount))
set('epno', padl(E.EpisodeNo, max(1, length(mepno)), '0') + version)
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)+')'))

// piece together the file name
set('filename', limit(limit(limit(atitle, 72) + ' - ' + epno + ' - ' + etitle, 130)  + ' ' + groupname, 150) + crc + '.' + F.FileType)

// Folder for first letter in anime title
set('head', copy(atitle, 72))
//if(numeric(head) or (head='.'), set('head', '0-9'))
set('head', head+'\')

// Subfolder for anime
set('head', head + limit(atitle, 72) + ' ' + '['+'anidb-'+A.Id+']' + '\')

// Prepend a subfolder for plot
//set('filename', if(A.Restricted, 'Hentai\') + head + filename)

// remove invalid characters
set('head', replace(head, '*', ' '))
set('head', replace(head, '/', ' '))
set('head', replace(head, '?', ' '))
set('head', replace(head, ':', ' '))
set('head', replace(head, '"', ' '))
set('head', replace(head, '<', ' '))
set('head', replace(head, '>', ' '))
set('head', replace(head, '|', ' '))
set('head', replace(head, '`', "'"))
set('head', replace(head, '  ', ' '))
set('head', replace(head, '~', ' '))

head

// 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, '  ', ' '))
set('filename', replace(filename, '~', ' '))

filename
gcs8
Posts: 18
Joined: 06 Apr 2024, 15:17

Re: Rename folders only for HAMA by [anidb-###]

Post by gcs8 »

update cuz bad at math V3
User avatar
rednoah
The Source
Posts: 23006
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders only for HAMA by [anidb-###]

Post by rednoah »

Doing the [anidb-###] bit with AoM scripting could be pretty useful to the AoM user community. Maybe add that bit to the docs for the next guy?
https://wiki.anidb.net/AniDB_O%27Matic_ ... e_renaming
:idea: Please read the FAQ and How to Request Help.
gcs8
Posts: 18
Joined: 06 Apr 2024, 15:17

Re: Rename folders only for HAMA by [anidb-###]

Post by gcs8 »

rednoah wrote: 09 Apr 2024, 07:26 Doing the [anidb-###] bit with AoM scripting could be pretty useful to the AoM user community. Maybe add that bit to the docs for the next guy?
https://wiki.anidb.net/AniDB_O%27Matic_ ... e_renaming
As soon as I am done debugging it. I keep finding oddness and I am the hellen keller of code.

current revision. v69

Groovy: Select all

// Anime title
set('atitle', at('en'))
if(length(atitle)=0, set('atitle', at('x-jat')))
if(length(atitle)=0, set('atitle', A.Name))
set('atitle', replace(atitle, '\', ' '))
if(start(atitle, '.'), set('atitle', copy(atitle, 2, length(atitle))))
set('atitle', replace(atitle, '...', ''))
set('atitle', replace(atitle, '1/2', '½'))
set('atitle', trim(atitle))
set('uncensored', (F.State and 64) > 1)
set('censored', (F.State and 128) > 1)

// 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('etitle', replace(etitle, '...', ''))
set('etitle', trim(etitle))

// Version
set('version', if(F.Version>1, 'v'+F.Version, ''))
set('v2n', version)

// Episode number and prefix
set('mepno', if(E.TypeId=1, max(A.TotalEpisodeCount, E.EpisodeTypeCount), E.EpisodeTypeCount))
set('epno', padl(E.EpisodeNo, max(1, length(mepno)), '0') + version)
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)+')'))

// piece together the file name
set('filename', limit(limit(limit(atitle, 72) + ' - ' + epno + ' - ' + etitle, 130)  + ' ' + groupname, 150) + crc + '.' + F.FileType)

// Folder for first letter in anime title
set('head', copy(atitle))
//if(numeric(head) or (head='.'), set('head', '0-9'))
//set('head', head+'\')

// Subfolder for anime
set('head', head + limit(atitle, 72) + ' ' + '['+'anidb-'+A.Id+']' + '\')

// Prepend a subfolder for plot
//set('filename', if(A.Restricted, 'Hentai\') + head + filename)

// remove invalid characters
set('head', replace(head, '*', ' '))
set('head', replace(head, '/', ' '))
set('head', replace(head, '?', ' '))
set('head', replace(head, ':', ' '))
set('head', replace(head, '"', ' '))
set('head', replace(head, '<', ' '))
set('head', replace(head, '>', ' '))
set('head', replace(head, '|', ' '))
set('head', replace(head, '`', "'"))
set('head', replace(head, '  ', ' '))
set('head', replace(head, '~', ' '))


head

// 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, '  ', ' '))
set('filename', replace(filename, '~', ' '))

filename
Post Reply