Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import os
- #Lets store the location of this directory to a variable loc
- loc = “~/Tutorials/Python/bucky_Python_Programming_Tutorials”
- #build a list of files from a give directory path and store the list to files variable
- files = os.listdir(loc)
- for index, each in enumerate(files):
- if index != 0:
- print index, each.split("-")[-1].split(".")[0]
- # the above 3 lines of code will print the file names from the directory,
- # alright lets dissect the above 3 lines
Advertisement
Add Comment
Please, Sign In to add comment