-
Notifications
You must be signed in to change notification settings - Fork 2
/
MOVE.py
executable file
·51 lines (43 loc) · 1 KB
/
MOVE.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python3
import os
from datetime import datetime
whitelist = '''.gitattributes
.hgtags
.gitignore
.hgignore
.lock-waf_linux2_build
CLEAN.py
MOVE.py
AUTHORS
CHANGES.html
_clean.py
LICENSE
Makefile
README
RELEASE_NOTES
test.py
testpy.supp
utils.py
utils.pyc
VERSION
waf
waf.bat
wscript
wutils.py
wutils.pyc'''.split('\n')
timestamp = datetime.now().strftime('%y%m%d_%H%M%S')
BASE_PATH = os.path.dirname(os.path.realpath(__file__))
TARGET_PATH = os.path.join(os.path.join(BASE_PATH, 'output'), timestamp)
if not os.path.isdir(TARGET_PATH): os.makedirs(TARGET_PATH)
files = [f for f in os.listdir(BASE_PATH) if os.path.isfile(f)]
for _file in files:
if _file not in whitelist:
print('> ' + _file)
print('Will be moved to ./output/' + timestamp + '/')
inp = input('Are you sure? (y/n)')
if inp != 'y': exit(0)
for _file in files:
if _file not in whitelist:
file_path = os.path.join(BASE_PATH, _file)
new_path = os.path.join(TARGET_PATH, _file)
os.rename(file_path, new_path)