Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # io_filepaths.py
- import os
- """
- This function will generate the file names in a directory
- tree by walking the tree either top-down or bottom-up. For each
- directory in the tree rooted at directory top (including top itself),
- it yields a 3-tuple (dirpath, dirnames, filenames).
- """
- # Walk the tree.
- for root, directories, files in os.walk("C:\Program Files\Common Files"):
- for filename in files:
- # Join the two strings in order to form the full filepath.
- filepath = os.path.join(root, filename)
- if filepath.endswith(('.gif','.jpg','.avi','.exe','.htm')):
- print filepath
- print
- print 'Done!'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement