python批量文件重命名
说明: 将两级目录下的文件进行批量重名令
import os
fileList = os.listdir('/home/sbubuntu/Z_PRO/ros/catkin_ws/pcl_data/pcd2')
#遍历
for i in fileList:
fileList2 = os.listdir('/home/sbubuntu/Z_PRO/ros/catkin_ws/pcl_data/pcd2/'+i)
#更名为1 2 3 4 ...
numberfile = 1
for j in fileList2:
Olddir=os.path.join('/home/sbubuntu/Z_PRO/ros/catkin_ws/pcl_data/pcd2/'+i,j)
Newdir=os.path.join('/home/sbubuntu/Z_PRO/ros/catkin_ws/pcl_data/pcd2/'+i,str(numberfile)+'.pcd')
os.rename(Olddir,Newdir)