比这篇新的文章:
Codee#7604
比这篇旧的文章: Codee#7602
作者: 半瓶墨水, 点击432次, 评论(0), 收藏者(0), , 打分:
所有评论,共0条:( 我也来说两句)
比这篇旧的文章: Codee#7602
把文件夹压平 flatten folders
语言: Python, 标签: 文件 2009/10/24发布 9个月前更新 更新记录作者: 半瓶墨水, 点击432次, 评论(0), 收藏者(0), , 打分:
Python语言: 把文件夹压平 flatten folders
01 #! /usr/bin/env python
02 # -*- coding: utf-8 -*-
03 # --filename:flat.py--
04 #
05 # 有时候需要把某个文件夹及其子文件夹下面的照片和视频通通导出到一个文件夹里
06 # 也就是把这个文件夹“压平”(flatten)
07 #
08 # 由于我的照片和视频文件名是不重复的,所以对于重复文件名的处理就没有做
09 #
10 #
11 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
12 print "!! !!"
13 print "!! NOTICE! this will DESTROY your folder! !!"
14 print "!! !!"
15 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
16
17 secret = raw_input("Enter 123abc to continue:")
18 if secret != "123abc":
19 print "you Entered " + secret, "WRONG answer!"
20 print "Aborted!!!"
21 import sys
22 sys.exit()
23
24 import os
25 from os.path import join, getsize
26 for root, dirs, files in os.walk('.'):
27 if root == ".": continue
28 for file in files:
29 cmd = 'move "' + join(root,file) + '" "' + file + '"'
30 print cmd
31 os.system(cmd)
32
33 for dir in os.listdir('.'):
34 if not os.path.isdir(dir): continue
35 cmd = "rd /s/q " + dir
36 print cmd
37 os.system(cmd)
02 # -*- coding: utf-8 -*-
03 # --filename:flat.py--
04 #
05 # 有时候需要把某个文件夹及其子文件夹下面的照片和视频通通导出到一个文件夹里
06 # 也就是把这个文件夹“压平”(flatten)
07 #
08 # 由于我的照片和视频文件名是不重复的,所以对于重复文件名的处理就没有做
09 #
10 #
11 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
12 print "!! !!"
13 print "!! NOTICE! this will DESTROY your folder! !!"
14 print "!! !!"
15 print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
16
17 secret = raw_input("Enter 123abc to continue:")
18 if secret != "123abc":
19 print "you Entered " + secret, "WRONG answer!"
20 print "Aborted!!!"
21 import sys
22 sys.exit()
23
24 import os
25 from os.path import join, getsize
26 for root, dirs, files in os.walk('.'):
27 if root == ".": continue
28 for file in files:
29 cmd = 'move "' + join(root,file) + '" "' + file + '"'
30 print cmd
31 os.system(cmd)
32
33 for dir in os.listdir('.'):
34 if not os.path.isdir(dir): continue
35 cmd = "rd /s/q " + dir
36 print cmd
37 os.system(cmd)
所有评论,共0条:( 我也来说两句)
代码
