import os
import shutil
from os import path

def main():
    directory = r'Ïóòü áåç ñëåøà â êîíöå' + '/'
    files = os.listdir(directory)
    for str_old in files:
        if os.path.isdir(directory + str_old):
            if '[sharewood.biz] ' in str_old:
                    str_new = str_old.replace('[sharewood.biz] ','')
                    os.rename(directory + str_old,directory + str_new)
                    print(str_old + ' OK')
            dir(directory,str_old.replace('[sharewood.biz] ',''))
        elif '[sharewood.biz] ' in str_old:
            str_new = str_old.replace('[sharewood.biz] ','')
            os.rename(directory + str_old,directory + str_new)
            print(str_old + ' OK')
        else:
            print(str_old)
def dir(directory,str_old):
    direct= directory + str_old + '/'
    print (direct)
    print (str_old)
    file = os.listdir(direct)
    print (file)
    for str_old in file:
        if os.path.isdir(direct + str_old):
            if '[sharewood.biz] ' in str_old:
                    str_new = str_old.replace('[sharewood.biz] ','')
                    os.rename(direct + str_old,direct + str_new)
                    print(str_old + ' OK')
            dir(direct,str_old.replace('[sharewood.biz] ',''))
        elif '[sharewood.biz] ' in str_old:
            str_new = str_old.replace('[sharewood.biz] ','')
            os.rename(direct + str_old,direct + str_new)
            print(str_old + ' OK')
        else:
            print(str_old)
        
if __name__ == "__main__":
    main()
 
