Guest User

Untitled

a guest
Jul 9th, 2021
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. #full path to folder containing the html files
  5. mydir = "C:/downloads/Yuki/vg.tar/vg"
  6.  
  7. #REGEX of the string you want to search
  8. prog = re.compile("(?i)(?<!not )an example string")
  9.  
  10. filelist = [ f for f in os.listdir(mydir) if f.endswith(".html") ]
  11. for f in filelist:
  12.     with open(os.path.join(mydir,f),encoding="utf8") as fc:
  13.         if prog.search(fc.read()):
  14.             fc.close()
  15.             print ("Moving %s",f)
  16.             os.rename(os.path.join(mydir,f), os.path.join("C:/downloads/Yuki/vg.tar/extracted",f))
  17.             #full path of the folder where you want files to be moved
Advertisement
Add Comment
Please, Sign In to add comment