You can use
the shorten() template function to construct file names where each segment has a maximum length and is shortened in a consistent way.
Using @DNSB's template as an example, the following ensures that the initial author_sort is never longer than 20 characters, the series is never longer than 15, the title is never longer than 25, and the first author is never longer than 20. The title and author split the value, placing an underscore between the parts. Thus the maximum length is 80 characters + the length of the series index + 8 (or so) for the fixed text in the template (brackets, slashes, hyphens, blanks).
Code:
{author_sort:'shorten(sublist($, 0, 1, '&'), 20, '', 0)'}/{series:'shorten($, 15, '', 0)'||} {series_index:|[|] - }{title:'shorten($, 15, '_', 9)'} - {authors:'shorten(sublist($, 0, 1, '&'), 10, '_', 9)'}
Example: for a test book with the following metadata:
- title: Test Title aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbb bbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccc cccccccccccccccccccccccccccccddddddddddddddddddddd ddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeee eeee
- author: Authorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, Test
- author_sort: Authorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, Test
- series: A Foobar Mumble Fratz
- series_index: 16.00
@DNSB's template without the shorten()s produces:
Code:
Authorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, Test/A Foobar Mumble Fratz [16] - Test Title aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccdddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee - Authorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, Test
The template with the shorten()s produces:
Code:
Authorrrrrrrrrrrrrrr/A Foobar Mumble [16] - Test Title aaaa_eeeeeeeee - Authorrrrr_rrr, Test