Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- import re
- homedir = os.path.dirname(os.path.realpath(__file__))+"/files" #FILES-nazwa folderu z plikami
- command=sys.argv[1].upper() #zawsze duze litery czy wpsize kk KK kK
- if command==('KK'):
- list_of_replace=[["dupa","kk"], \
- ["xd","KK"], \
- ["mam na", "kk"]]
- list_of_regex=[["([`\.])(Arial Baltic|Arial CE|Arial CYR|Arial TUR|Arial Greek|Batang)('|\1)","\1Arial\3"]]
- elif command=="VI":
- list_of_replace=[["dupa","odbyt"], \
- ["xd","lol"]]
- else:
- print ("dodaj argument w wierszu polecen glupku")
- #Mam na imie dupa i lubie sobie robic xd xd xd.
- #wrzucanie naz plikow do listy
- list_of_files=[]
- for file in os.listdir("%s" % homedir):
- list_of_files.append(file)
- for file in list_of_files:
- #otwiera plik
- with open("{}/{}".format(homedir, file), "r+") as f:
- old = f.read()
- #zamienai stringi
- for string_to_find in list_of_replace:
- old=old.replace(string_to_find[0], string_to_find[1])
- #zamiena regexy
- for regex_to_find in list_of_regex:
- old=re.sub(regex_to_find[0], regex_to_find[1], old)
- #nadpisuje plik
- f.seek(0)
- #print (old)
- f.write(old)
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement