Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. from os import *
  2.  
  3. #GetFileList Pseudo-code:
  4. #List Target Directory, Check each file, if is directory, Call This function storing return value in its current return value. when all done return the current list
  5. #that contains directory contents. Do not store directories, only files. if is a directory remove it from list so it isn't in there.
  6. def ListFiles(target_directory = "./", excluded_filenames=[]):
  7.     fileList = listdir(target_directory)
  8.     for tmpFileLocation in range(0,(len(fileList)-1)):
  9.  
  10.         if (fileList[tmpFileLocation] in excluded_filenames):
  11.             fileList.pop(tmpFileLocation)
  12.             continue;
  13.        
  14.         if (path.isdir(fileList[tmpFileLocation])):
  15.             for tmpFile in ListFiles(target_directory+fileList[tmpFileLocation]+"/"):
  16.                 fileList.append(fileList[tmpFileLocation]+"/"+tmpFile)
  17.             fileList.pop(tmpFileLocation) #Was a directory get rid of it, we only want files in this list
  18.  
  19.     return fileList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement