python文件自动归类工具一个简单的python小程序

2018年11月10日09:57:36 发表评论 1,343 views


path = 'D://Users/Administrator/Desktop/Walden'
path2 = path + '/'
files = os.listdir(path)

for f in files:
    folder_name = path + f.split('.')[-1]
    folder_name2 = path2 + f.split('.')[-1]
    if not os.path.exists(folder_name2):
        os.makedirs(folder_name2)
        shutil.move(path2+f,folder_name2)
    else:
        shutil.move(path2 + f,folder_name2)

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: