Archive for December, 2010

Sequence Rename

small python Sequence Rename
[Python]
import os
import re
def readSequence(seqDir):

getAllfileList = os.listdir(seqDir)
for eachFile in getAllfileList:
reExp = re.compile(‘[0-9]+’)
#print os.path.splitext(eachFile)
getFileNumcnt = reExp.search(eachFile).group()
newIntValue = ‘%04d’%int(getFileNumcnt)
newFileName = ‘%s/%s.%s%s’%(seqDir,os.path.splitext(eachFile)[0].split(‘_’)[0],newIntValue,os.path.splitext(eachFile)[-1])
oldFileName = ‘%s/%s’%(seqDir,eachFile)
print oldFileName,newFileName
os.rename(oldFileName,newFileName)
readSequence(‘/home/******/***/hrender’)
[/Python]