Advertisement
Guest User

ls

a guest
Aug 22nd, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. import os
  2.  
  3. # quickly list files in a dir with specific filetype
  4. # without recursion into subdirs
  5.  
  6. thepath = '/Your_Dir/'   # some path
  7. filetype = '.py'         # use this format .bla
  8.  
  9. le=len(filetype)
  10. pdffiles = [i for i in os.listdir(thepath) if i[-le:] == filetype]
  11. for afile in pdffiles:
  12.   print afile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement