I’m told I can put a bit of JS into the file name field of an output preset. True?
If so, I’d like to have the number of sheets in the file name as well as either D if sheets.duplex is true or S if sheets.simplex is true, and add a file number at the end.
What I have below doesn’t work, could someone help me see what I’m missing?
Error I get is:
22:39:16.581 [0014] W3001 : Error while executing plugin: HTTP/1.1 500 LoggedApplicationException: There was an error running the output creation process caused by ApplicationException: error evaluating expression ‘document.count.sheets’ at line 1, column 13 in pattern ‘Statement_${document.count.sheets}{if(${sheet.duplex}){‘D’}else{‘S’}}${file.nr}.pdf’
Note
When using a variable in a condition, do not wrap it in ${ }. This notation is only necessary in the context of a text (like file names or additional page content).
The syntax for using a condition within the name would be like this:
myFileName_${if(1==1){‘true’} else {‘false’}}.pdf
However, sheet.duplex isn’t a variable that would be available to you in the output mask. See the difference between File Name variables and Content Variables in the documentation listed by @hamelj. Some Content variables are available to you in the name, but only if you’re using separation to bring you down to that level. For example, document.count.sheets becomes available if, and only if, you’re separating on the document level. If not, that variable will cause an error.
The variables listed below can be used in text, barcodes, and OMR and Image data in the Additional Content page, and in the Conditional field when selectively adding inserts in the Inserter Options.
If the output is grouped and separated, Content variables on the separation level and above are also available as File name variables. For example, if the output is grouped on the job segment and document set level, and is to be separated on the Document Set level, the set and segment variables can also be used in the Job Output Mask field.
Since there’s no separation level for something as low level as a single sheet, these are out of reach in the name. They only become relevant in conditions in the Add Additional Content section of output. For example, to only print a special element on the back of the page if it’s already duplex.
Tried what hamelj suggested but it didn’t work.
I then tried this using AlbertsN example:
Statement_${if(document.count.pages%2==0){document.count.pages}else{document.count.pages+1}}{if(document.count.pages%2==0){D}else{S}} ${file.nr}.pdf
but this didnt quite work either. The result was output PDF files each with an incomplete filename like so:
Statement_2{if(document.count.pages%2==0){D}else{S}} 1.pdf
Statement_4_{if(document.count.pages%2==0){D}else{S}} 4.pdf
Looks like the sheet count evaluated OK, but the second if statement wasn’t evaluated. Can you tell me what is missing?
thanks!
I found the problem, the following statement works:
Statement_${if(document.count.pages%2==0){document.count.pages/2}else{(document.count.pages/2)+1}}${if(document.count.pages/2==1){‘S’}else{‘D’}}${file.nr}.pdf