elkclone

listdir of files

Feb 18th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. #!/usr/bin/python
  2. #takes a directory as a command line argument. it lists the dir
  3. import sys
  4. import re
  5. import os
  6. def List(dir):
  7.     filenames = os.listdir(dir)
  8.     for filename in filenames:
  9.         path = os.path.join(dir, filename)
  10.         print os.path.abspath(path)
  11.  
  12. #main() to dump file to screen
  13. def main():
  14.     List(sys.argv[1])
  15.  
  16. #boilerplate main() call.
  17. if __name__=='__main__':
  18.    main()
Advertisement
Add Comment
Please, Sign In to add comment