Я использовал Python для редактирования файла.
#!/usr/bin/python
# this script populates the scribus template for the SN of FuelSpy
# Olmo Mezger
import re # regular expression
import os.path #for os path operations
#config
myFile_Tempate = "SN_Template.sla"
myFile_Out = "SN_Tier_01.sla"
i_start = 1
i_number = 27*7
# check if file exists
if os.path.isfile(myFile_Out):
print 'aborting, output file exist and I dont want to overwrite it. Delete it manually if you want to continue',
#quit()
else:
print 'continue'
#
f_in = open(myFile_Tempate, 'r')
f_out =open(myFile_Out, 'w')
# loop
i = i_start
for line in f_in:
#print line
myString = line
if myString.find('%') == -1: # it does not have %
f_out.write(myString)
else:
myNumber = '%0*d' % (4, i)
myNewString = myString.replace('%',myNumber)
#print myNewString
f_out.write(myNewString)
print i
i = i+1
f_in.close()
f_out.close()
print "done"