There is a sample script in the Scripts folder that you can use for this called ExternalProcessSampleScript.bat.
Make a copy of it. Give the copied file a name. For instance QuantityFromJobName.bat. Edit the copied file using some text editor and comment out or remove the indexes you don't need but keep:
set VariableValuePair.Name=$FFwfJob.printQuantity$ set VariableValuePair.Value=0
In an External Process in the workflow use the the edited bat file as script and set the parameters.
I have used "$FFwfJob.jobName.substring(-3,3)$" as an example and you need to enter the appropriate values in your case. You also need to include the additional variable "$FFwfJob.printQuantity$". This way the substring taken from the job name will be passed to the variable for the print quantity.