import os,time,shutil
formats = {
"音频"
:[
".mp3"
,
".wav"
],
"视频"
:[
".mp4"
,
".avi"
,
".mov"
,
".wmv"
,
".asf"
,
".rm"
,
".rmvb"
],
"图片"
:[
".jpeg"
,
".jpg"
,
".png"
,
".gif"
,
".bmp"
,
".psd"
,
".html"
],
"文档"
:[
".txt"
,
".pdf"
,
".doc"
,
".docx"
,
".xlsx"
,
".pptx"
],
"压缩"
:[
".zip"
,
".rar"
,
".7z"
,
".jar"
],
}
path =
"D:\\桌面"
dirs = os.listdir(path)
filename=
"桌面缓冲文件"
+time.strftime(
'%Y:%m:%d'
,time.localtime(time.time())).replace(
":"
,
"_"
)
filepath=
"D:\\Source_SBUF\\"
+filename
os.mkdir(filepath)
for
file
in
dirs:
fname,ext = os.path.splitext(file)
for
d,exts
in
formats.items():
if
ext
in
exts:
shutil.move(path+
"\\"
+file,filepath+
"\\"
+file)
print(ext)