zoukankan      html  css  js  c++  java
  • 用python 重命名文件夹下文件

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

  • 相关阅读:
    http
    VUE-1
    AJAX
    html常用标签
    CSS网页布局
    概念整理3
    SEO
    概念整理2
    var
    概念整理
  • 原文地址:https://www.cnblogs.com/TendToBigData/p/10501239.html
Copyright © 2011-2022 走看看