# -*- 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
'''

相关文章:

  • 2022-03-10
  • 2022-01-27
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-09-27
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-30
  • 2021-08-03
  • 2022-12-23
  • 2022-02-13
  • 2021-06-18
相关资源
相似解决方案