SEESenv/scripts/changenames.py
author amit@thunder
Thu, 04 Mar 2010 14:33:38 +0530
changeset 43 134b87b382f5
parent 41 e54725be4df6
child 44 d0e9b52bda73
permissions -rw-r--r--
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)