It also depends on what you actually mean by "shorter".
If you mean fewest lines of code then all of highend's suggestions are good but I'd add the obvious:
Code: Select all
$e = get("curitem", "ext");
if ($e == 'srt' || $e == 'ass' || $e == 'ssa') {rename b, '<clipboard>.en'}
else {rename b, <clipboard> };
And I might prefer GetTokenIndex...
Code: Select all
rename 'b', <clipboard> . (GetTokenIndex(<curext>, 'srt|ass|ssa',, 'ic') ? '.en' : '');
If you want less complication then using the recently introduced switch-case is a great choice:
Code: Select all
function NewExt($e) {
switch (Recase($e,'l')) {
case 'srt':
case 'ass':
case 'ssa':
return '.en';
default:
return '';
}
}
rename 'b', <clipboard> . NewExt(<curext>);