import os
import shutil
current_path = os.path.dirname(os.path.abspath(__file__))
source_path = current_path
#分类目标文件夹
raw_target = current_path + '/raw'
jpg_target = current_path + '/jpg'
print("current_path")
print(current_path)
files = os.listdir(source_path)
for file in files:
if file.endswith('.CR3') or file.endswith('.cr3'):
print(file)
shutil.move(source_path + '/' + file, raw_target + '/' + file)
print('文件{}已移到raw文件夹'.format(file, ))
continue
elif file.endswith('.JPG') or file.endswith('.jpg'):
print(file)
shutil.move(source_path + '/' + file, jpg_target + '/' + file)
print('文件{}已移到jpg文件夹'.format(file, ))
continue
else:
print(file+' 其他类型')
使用Python根据文件后缀名整理文件
最新推荐文章于 2023-06-16 18:41:00 发布