Python - Remove files by extension
a guest Aug 10th, 2013 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import os
- def remove_by_ext(path,ext):
- '''Walks through directories removing files with specified extension'''
- for (path,dirs,files) in os.walk(path):
- for file_name in files:
- if file_name_lower[-len(ext):] == ext.lower():
- print('File removed: %s' %file_name)
- path = raw_input('Input Path: ')
- ext = raw_input('Input Extension: ')
RAW Paste Data