Guest User

Untitled

a guest
Jan 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. dir_name = "/Python/Test_folder" # open the folder and read files
  5. testfolder = os.listdir(dir_name)
  6.  
  7. def matching(r, s): # condition if there's nothing to match
  8. match = re.search(r, s)
  9. if match:
  10. return match.group()
  11. return "Files don't exist!"
  12.  
  13. matching(r'^ww[_]wwww[1][7]w+[.]w+', testfolder) # matching the file's mask
  14.  
  15. for item in testfolder.index(matching):
  16. if item.name(matching, s):
  17. os.remove(os.path.join(dir_name, item))
  18.  
  19. # format of filenames not converted : ??_????17*.*
  20. # convert for python separarately : [w][w][_w][w][w][w][1][7][w]+[.][w]+
  21. # ? - Any symbol 1..n,A..z w repeating is *
  22. # * - Any number of symbols 1..n, A..z
  23. # _ and 17 - in any files `
Add Comment
Please, Sign In to add comment