Made changes so that the files so that files above chapter 10 do not come twice also changed the name so that any chapter beyond 9 is listed in the end
import glob
import subprocess
import re
import time
import os
import sys
repo=sys.argv[1]
names= glob.glob(os.path.join(repo,'ch1*.html'))
for name in names:
reg_obj=re.compile(os.path.join(repo,'ch1[0-9].*.html'))
if (reg_obj.match(name)):
changed_name=re.sub('ch1','chn1',name)
command2="rm %s" %(name,)
else:
changed_name=name
command1="cp %s %s" %(name ,changed_name)
subprocess.Popen(command1,shell=True)
time.sleep(2)
subprocess.Popen(command2,shell=True)
time.sleep(1)