Created
January 16, 2011 01:32
-
-
Save roopeshvaddepally/781449 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# LICENCE: GPLv3 | |
# temp files '.*~' from given directories or starting at home directory | |
# usage: rm_temp.py <arg1> <arg2> ... <argn> | |
# ouputs: log of which directory it is working in | |
import os | |
import sys | |
import logging | |
logger = logging.getLogger(__file__.split(".")[0]) | |
logger.setLevel(logging.INFO) | |
channel = logging.StreamHandler() | |
channel.setLevel(logging.DEBUG) | |
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s") | |
channel.setFormatter(formatter) | |
logger.addHandler(channel) | |
if len(sys.argv) > 1: | |
for each in sys.argv[1:]: | |
logger.info("removing temp files from directory %s" % each) | |
os.system(r"find %s -regex .*~$ -exec rm '{}' \;" % each) | |
else: | |
logger.info("removing temp files starting at home directory") | |
os.system(r"find ~ -regex .*~$ -exec rm '{}' \;") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment