sanfx

print_filenames.py

Aug 17th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. Import os
  2. #Lets store the location of this directory  to a variable loc
  3. loc =~/Tutorials/Python/bucky_Python_Programming_Tutorials”
  4. #build a list of files from a give directory path and store the list to files variable
  5. files = os.listdir(loc)
  6.  
  7. for index, each in enumerate(files):
  8.     if index != 0:
  9.         print index, each.split("-")[-1].split(".")[0]
  10.  
  11. # the above 3 lines of code will print the file names from the directory,
  12. # alright lets dissect the above 3 lines
Advertisement
Add Comment
Please, Sign In to add comment