Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- #full path to folder containing the html files
- mydir = "C:/downloads/Yuki/vg.tar/vg"
- #REGEX of the string you want to search
- prog = re.compile("(?i)(?<!not )an example string")
- filelist = [ f for f in os.listdir(mydir) if f.endswith(".html") ]
- for f in filelist:
- with open(os.path.join(mydir,f),encoding="utf8") as fc:
- if prog.search(fc.read()):
- fc.close()
- print ("Moving %s",f)
- os.rename(os.path.join(mydir,f), os.path.join("C:/downloads/Yuki/vg.tar/extracted",f))
- #full path of the folder where you want files to be moved
Advertisement
Add Comment
Please, Sign In to add comment