File size: 1,029 Bytes
6b360b1
 
 
 
 
 
 
 
 
 
 
 
2c7e501
6b360b1
 
 
 
 
 
 
 
 
 
 
 
 
 
2c7e501
6b360b1
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os

def replace_url_in_file(file_path, old_url, new_url):
    try:
        with open(file_path, 'r', encoding='utf-8') as file:
            filedata = file.read()

        filedata = filedata.replace(old_url, new_url)

        with open(file_path, 'w', encoding='utf-8') as file:
            file.write(filedata)
    except Exception as e:
        pass

def replace_url_in_folder(folder_path, old_url, new_url):
    for root, dirs, files in os.walk(folder_path):
        for file in files:
            file_path = os.path.join(root, file)
            replace_url_in_file(file_path, old_url, new_url)

folder_path = 'stable-diffusion-webui-forge/' # 替换为你的文件夹路径
old_hugging = 'huggingface.co' # 替换为你要替换的旧URL
new_hugging = 'hf-mirror.com' # 替换为你要替换的新URL
old_git = "https://github.com"
new_git = "https://gh.con.sh/https://github.com"
replace_url_in_folder(folder_path, old_hugging, new_hugging)
replace_url_in_folder(folder_path, old_git, new_git)
print("ALL DONE!")