Quote:
Originally Posted by fidvo
FWIW, here is my Save to Disk template:
Code:
program:
switch(current_library_name(),
'Library - Main',
template('{#path:re(\.,/)}/{series_index:0>3s||_}{#subseries}{#subseries_index:0>3s||_}{title}'),
'Library - Special',
template('{#path:re(\.,/)}/{series_index:0>3s||_}{title}'),
'Library - In Progress',
template('{author_sort}/{series}/{series_index:0>3s}_{title}'),
template('{#path:re(\.,/)}/{#seriesid:re(\.,/)}{#titleid:re(\.,/)}'))
Note that "path" is a custom field I set up, not the path to the file. (In hindsight I should have named it something else)
|
Invoking templates inside GPM is ugly (and slower)

why not use this?
Code:
program:
# Initialize repetitive and/or complicated values for later use.
path = re(
field('#path'),
'\.',
'/'
);
seriesid = re(
field('#seriesid'),
'\.',
'/'
);
titleid = re(
field('#titleid'),
'\.',
'/'
);
sidx = finish_formatting(
field('series_index'),
'0>3s',
'',
'_'
);
subsidx = finish_formatting(
field('#subseries_index'),
'0>3s',
'',
'_'
);
# Compute final return value.
switch(
current_library_name(),
'Library - Main',
strcat(
path, '/', sidx, field('#subseries'), subsidx, field('title')
),
'Library - Special',
strcat(
path, '/', sidx, field('title')
),
'Library - In Progress',
strcat(
field('author_sort'), '/', field('series'), '/', sidx, field('title')
),
strcat(
path, '/', seriesid, titleid
)
)