import os
import shutil
path = input("Please input path:")
files = os.listdir(path)
for file in files:
file_ext = file.split('.')[-1]
file_folder = os.path.join(path, file_ext)
if not os.path.exists(file_folder):
os.makedirs(os.path.join(path, file_ext))
shutil.move(os.path.join(path,file), file_folder)
else:
shutil.move(os.path.join(path,file), file_folder)
Python练手小脚本-按后缀分类文件
最新推荐文章于 2024-09-09 00:00:00 发布