Skip to content

Instantly share code, notes, and snippets.

@mintisan
Created January 25, 2016 16:05
Show Gist options
  • Save mintisan/448c96046660d9892228 to your computer and use it in GitHub Desktop.
Save mintisan/448c96046660d9892228 to your computer and use it in GitHub Desktop.
classify specific file type into a txt within current directory
# -*- coding: utf-8 -*-
import os
import re
def classify_file_type_in_current_dir(file_name, file_type):
f = open(file_name,'wb')
for root, dirs, files in os.walk(os.getcwd(), topdown=True):
for name in files:
if re.search(file_type, name):
f.write(name + '\n')
f.flush()
f.close()
file_type = '.py'
file_txt = 'file_list_py.txt'
classify_file_type_in_current_dir(file_txt, file_type)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment