Guest User

Untitled

a guest
Apr 25th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import os, sys
  2.  
  3. # get args from input sans first item, which is the name of this file
  4. args = sys.argv[1:]
  5.  
  6. # adds missing slash to the end of a string
  7. def add_end_slash(s):
  8. if s[-1:] != "/":
  9. s += "/"
  10. return s
  11.  
  12. folder = add_end_slash(args[0])
  13.  
  14. # loop through passed in directory for filenames
  15. for root, dirs, files in os.walk(folder):
  16. for name in files:
  17. filename = os.path.join(root, name).replace(folder, '')
  18. print "<file href=\"" + filename + "\" />"
Add Comment
Please, Sign In to add comment