#!/usr/bin/env python #coding=utf8 ''' Python ver 2.7 Search some file recursivily ''' import os import fnmatch def recursiveSearchFile(searchPath, partInfo): wantFilesPath = [] for (dirPath, dirNames, fileNames) in os.walk(searchPath): wantFilesPath += [os.path.join(dirPath, fileName) for fileName in fileNames if fnmatch.fnmatch(os.path.join(dirPath, fileName), partInfo)] return wantFilesPath if __name__ == "__main__": fileList = recursiveSearchFile('C:\UsersAdministrator\Desktop', '*.pl') for path in fileList: print path