Created
January 25, 2016 16:05
-
-
Save mintisan/448c96046660d9892228 to your computer and use it in GitHub Desktop.
classify specific file type into a txt within current directory
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
# -*- 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