-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean.py
32 lines (30 loc) · 891 Bytes
/
clean.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
import os
import shutil
def data_and_fig():
folder_names = ['data', 'fig']
for item in folder_names:
shutil.rmtree(item, ignore_errors=True)
os.mkdir(item)
def these_extensions(file_extensions):
all_files = os.listdir(os.getcwd())
for file in all_files:
for ext in file_extensions:
if file.endswith(ext):
remove_if_exists(file)
def remove_if_exists(filename):
if os.path.exists(filename):
os.remove(filename)
return(print("Removed", filename))
else:
pass
if __name__ == '__main__':
pass
# print("Cleaning..")
# yesorno = 'yes'
# #yesorno = input("Do you want to clean the data ? (yes or no)\n")
# if yesorno =='yes':
# data_and_fig()
# these_extensions()
# print("Done")
# else:
# print("Do nothing")