1. 程式人生 > >文件分類

文件分類

shutil dir test AD auth not exists move utf

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : 文件分類.py
# @Author: Anthony.waa
# @Date : 2018/5/8 0008
# @Desc :

import os
import shutil

paths = ‘C:/Users/Administrator/Desktop/test/‘

files = os.listdir(paths)
list_dir = os.listdir(paths)

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




文件分類