Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- dir_name = "/Python/Test_folder" # open the folder and read files
- testfolder = os.listdir(dir_name)
- def matching(r, s): # condition if there's nothing to match
- match = re.search(r, s)
- if match:
- return match.group()
- return "Files don't exist!"
- matching(r'^ww[_]wwww[1][7]w+[.]w+', testfolder) # matching the file's mask
- for item in testfolder.index(matching):
- if item.name(matching, s):
- os.remove(os.path.join(dir_name, item))
- # format of filenames not converted : ??_????17*.*
- # convert for python separarately : [w][w][_w][w][w][w][1][7][w]+[.][w]+
- # ? - Any symbol 1..n,A..z w repeating is *
- # * - Any number of symbols 1..n, A..z
- # _ and 17 - in any files `
Add Comment
Please, Sign In to add comment