Padding variables with leading zero's
Print Distributor has several numeric fields which you can include in the path of a Write File action. These include ?SN? for a unique serial number, ?ID? for the job identifier, ?TP? for the total pages in the print job and ?SI? for the size of the spool file.
When you include any of these fields in the path they will be translated into the corresponding number without any padding. If you want to pad out one of these numbers with leading zero's you can do this with a small script using the Script action.
We have to cheat a little to fool Print Distributor into doing this because these fields are all numeric so they automatically strip any leading zero's. To do this we put the padded number in a spare text field, in this example we will use the ?NN? (NotifyName) field as it doesn't get used very often.
We will start by adding a script action in Print Distributor and pasting in this code:
' Script to pad out the serial number field and
' with leading zero's
'
' The result gets stored in the ?NN? NotifyName field
NotifyName = SerialNumber
Do While Len(NotifyName) < 6
NotifyName = "0" & NotifyName
Loop
This action needs to be at the top of the list of actions so it will be executed first. If it isn't in your case select it then use the Up button to move it to the top.

To use the padded version of our serial number we add the ?NN? field in the Write File action, it should look something like this:

Finally our prints should now be printed to file with unique serial numbers with leading zero's:
