No matter what I try, “i” always stays as “1”. I am trying a add “1” to “i” each time it goes to the next file containing “1Chr” in the folder.
python
for name in glob.glob('*.html'):
i = 1
with open(name) as k:
content = k.read()
if '1Chr.'+str(i)+'.' in name:
book = name.split('.')[0].upper().rstrip()
x=open('final/'+book+'.SFM', 'a')
x.write(content)
i += 1
x.close()
Place the
i = 1above your for loop.For every new file, you are resetting
ito be one, so it can’t go beyond 2.