简单小练习_自动收集文件到文件夹

import os
import shutil

path='./'
files = os.listdir(path)

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

 

posted @ 2018-06-13 17:34  Erick-LONG  阅读(153)  评论(0编辑  收藏  举报