# -*- coding: utf-8 -*-
import os
'''
Description:
when we load xls data into unix ,the file name with some space while our process can not recognise those file,
so we want to write a samll a process and put it on unix to rename the files
'''
def renamefile():
path = 'C:\Users\IBM_ADMIN\Desktop\cognos\datastage\excel\1Q-4Q files'
filelist = os.listdir(path)
for file in filelist:
Oldfile = os.path.join(path,file)
if os.path.isdir(Oldfile):
continue
filename=os.path.splitext(file)[0]
filetype=os.path.splitext(file)[1]
newfilename = filename.replace(' ','_')
Newfile=os.path.join(path,newfilename+filetype)
os.rename(Oldfile,Newfile)
print "Process is going...."
renamefile();
print "Process done"
'''
ls -lt target*| head -10
'''