-
Notifications
You must be signed in to change notification settings - Fork 155
[AniDB] AniAdd
BrutuZ edited this page Nov 13, 2021
·
2 revisions
Script to rename and organize an Anime Library:
Trunc(str, len):= $repl(%str%, ".{" $len($repl(%str%, "(.?){" %len% "}$", "")) "}$", "")
TruncEllipse(str, len):= { $len(%str%) = $len($Trunc(%str%, %len%)) ? %str% : $Trunc(%str%, %len%) "..." }
TooLong(path):= { $max($len(%path%), "256") = "256" ? "0" : "1" }
AT:=[%ATr%,%ATe%,%ATk%]
AT:= $repl(%AT%,'^\.',"dot")
AT:= $repl(%AT%,'[\\\":/*|<>?]',"")
AT:= $repl(%AT%,' \([0-9][0-9][0-9][0-9]\)$',"")
ET:=[%ETe%,%ETr%,%ETk%]
GT:=" [" [%GTs%,%GTl%] "]"
GT:=$repl(%GT%," \[raw\]","")
GT:=$repl(%GT%," \[\]", "")
CRC:="("$uc(%FCrc%)")"
NaN:= $repl(%EpNo%, "[0-9]", "_")
EpNoPad:= { $substr(%NaN%, "0", "1") = "_" ? $pad(%EpNo%,$max($len(%EpHiNo%),$len(%EpCount%)),"0") : %EpNo% }
Ver:={%Ver%="1"?"":"v"%Ver%}
FileNameLong:=%AT%" - "%EpNoPad% %Ver%" - "%ET%%GT%%CRC%
FileNameMedium:=$TruncEllipse(%AT%,"79")" - "%EpNoPad% %Ver%" - "$TruncEllipse(%ET%, "17")%GT%%CRC%
FileNameShort:=$TruncEllipse(%AT%,"97")" - "%EpNoPad% %Ver%%GT%%CRC%
PathNameLong:="D:\Anime\" %AT%" ("%AYearBegin%") [anidb-"%AId%"]"
PathNameShort:="D:\Anime\" $TruncEllipse(%AT%,"76")" ("%AYearBegin%") [anidb-"%AId%"]"
FullPathLong:=%PathNameLong% "\" %FileNameLong%
FullPathMedium:=%PathNameLong% "\" %FileNameMedium%
FullPathShort:=%PathNameLong% "\" %FileNameShort%
FullPathShort2:=%PathNameShort% "\" %FileNameMedium%
FileName:={$TooLong(%FullPathLong%)="1" ? {$TooLong(%FullPathMedium%)="1" ? {$TooLong(%FullPathShort%)="1" ? {$TooLong(%FullPathShort2%)="1" ? %FileNameShort% : %FileNameMedium%} : %FileNameShort%} : %FileNameMedium%} : %FileNameLong%}
PathName:={$TooLong(%FullPathLong%)="1" ? {$TooLong(%FullPathMedium%)="1" ? {$TooLong(%FullPathShort%)="1" ? %PathNameShort% : %PathNameLong%} : %PathNameLong%} : %PathNameLong%}