Skip to content

Instantly share code, notes, and snippets.

@AllanLRH
Created April 16, 2014 11:29
Show Gist options
  • Save AllanLRH/10857007 to your computer and use it in GitHub Desktop.
Save AllanLRH/10857007 to your computer and use it in GitHub Desktop.
Cleans the files left over from LaTeX compulation
#!/usr/bin/env python
# -*- coding: utf8 -*-
from __future__ import division
from __future__ import print_function
from os import listdir, remove
from sys import argv
fileEndings = {'aux',
'fdb_latexmk',
'idx',
'ilg',
'ind',
'log',
'out',
'toc',
'fls',
'synctex.gz',
'texlog',
'bbl',
'blg',
'brf',
'lof',
'lol',
'lot',
'gz',
'nav',
'snm',
'tdo',
'thm',
'run.xml'}
def cleanFolder(path):
files = listdir(path)
for f in files:
if f.split('.')[-1] in fileEndings:
try:
remove(f)
except OSError:
print('Could not remove file ' + f)
if __name__ == '__main__':
if len(argv) > 1:
cleanFolder(argv[1])
else:
cleanFolder('.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment