用python 重命名文件夹下文件
来源:互联网 发布:mysql 倒序 编辑:程序博客网 时间:2024/05/16 02:14
# -*- 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'''
阅读全文
0 0
- 用python 重命名文件夹下文件
- C++实现某文件夹下文件重命名
- 读取文件夹下文件,获取文件名,重命名
- Python批量对目录下文件重命名
- Python批量重命名指定文件夹下文件的两种方法
- 目录下文件重命名
- python 列举文件夹下文件并排序
- Python实例31[批量对目录下文件重命名]
- 遍历文件夹下文件
- 遍历文件夹下文件
- 遍历文件夹下文件
- python统计某一个文件夹下文件总行数
- Python 读取文件夹下文件列表 自然排序
- Python 实现删除某路径下文件及文件夹
- python统计某路径下文件个数,文件夹个数
- ASP.NET下文件下载时重命名
- PHP遍历文件夹下文件
- android遍历文件夹下文件
- 编译工具的php项目(一)
- js中getBoundingClientRect()方法详解
- 下拉刷新与加载,不影响listview或者recycleview本身
- 欢迎使用CSDN-markdown编辑器
- java中网络编程DatagramPacke类------UDP协议
- 用python 重命名文件夹下文件
- JS基础复习
- ADO.NET学习之SqlConnection,SqlCommand
- Picasso简介<一>
- vue2.0 自定义日期时间过滤器
- Bundle adjustment学习
- Redis和Memcache的区别分析
- 有哪些老鸟程序员知道而新手不知道的小技巧?
- Java动态代理