Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- path_txt = (r'C:UsersusuarioDesktopfiles')
- name_files = os.listdir(path_txt)
- for TXT in name_files:
- with open(path_txt + '\' + TXT, "r") as content:
- search = re.search(r'(([0-9]{4})(/)(([1][9][0-9][0-9])|([2][0-9][0-9][0-9])))', content.read())
- if search is not None:
- os.rename(os.path.join(path_txt, TXT),
- os.path.join("Processos3", search.group(0) + "_" + str(random.randint(100, 999)) + ".txt"))
Add Comment
Please, Sign In to add comment