robertvari

List files

Aug 31st, 2018
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. # unicode(folderPath) for non ascii characters in file/folder names
  2.  
  3. # list .mkv files in folder
  4. movieFiles = [folderPath + "/" + i for i in os.listdir(unicode(folderPath)) if i.endswith(".mkv")]
  5.  
  6.  
  7. # does the same recursively with os.walk
  8. movieFiles = [os.path.join(dp, f) for dp, dn, filenames in os.walk(unicode(folderPath)) for f in filenames if
  9.               os.path.splitext(f)[1] == '.mkv']
Advertisement
Add Comment
Please, Sign In to add comment