here2share

# t_find_by_extensions.py

Jan 17th, 2021 (edited)
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. # t_find_by_extensions.py
  2.  
  3. from tkFileDialog import askdirectory
  4. folder = askdirectory() # needs to be placed after pack()
  5. import os
  6.  
  7. filenames = os.listdir(folder)
  8. print(folder)
  9. print
  10. extensions = '.jpg .jpeg .png'.split()
  11. for file in filenames:
  12.         if any([file.endswith(z) for z in extensions]):
  13.             print('***\t\t'+file)
  14.         else:
  15.             print(file)
Add Comment
Please, Sign In to add comment