#! /usr/bin/env python

import os,sys

def main():
	argc = len(sys.argv)
	if argc < 2:
		print "usage: ", sys.argv[0], " [dir] [suffix]"
		sys.exit(1)
	path = sys.argv[1]
	suffix = sys.argv[2]
	files = os.listdir(path)
	os.chdir(path)
	for fname in files:
		s = fname.split('.')
		s = s[-1]
		if s != suffix:
			if (os.path.isdir(fname)):
				os.rmdir(fname)
			else:
				os.remove(fname)
if __name__ == '__main__':
	main()
