-
Notifications
You must be signed in to change notification settings - Fork 0
/
CleanUp.py
executable file
·33 lines (26 loc) · 927 Bytes
/
CleanUp.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
import os
'''
This is a file which allows for the reduction of the
files present in the reference file output folders, removing
the non-essential files which are created by pdflatex
'''
path = os.getcwd()
base_contents = os.listdir(path)
folders = []
contents = []
keep_extensions = ['pdf', 'tex']
def find(targets):
for folder in targets:
folders = os.listdir(folder)
for group in folders:
contents = [doc for doc in \
os.listdir(os.path.join(folder, group))\
if doc.split('.')[-1] not in keep_extensions]
clear(os.path.join(folder, group), contents)
def clear(path, contents):
print path
for file in contents:
os.remove(os.path.join(path, file))
targets = [folder for folder in base_contents if folder[:4] == 'lrg ']
targets.append('output')
find(targets)