import os import re def update_file_links(file_path): with open(file_path, 'r', encoding='utf-8') as f: content = f.read() # Replace the old file names with new ones content = content.replace('房源管理_二手房源.html', '二手房服务_户型管理.html') content = content.replace('房源管理_租房房源.html', '租房服务_户型管理.html') with open(file_path, 'w', encoding='utf-8') as f: f.write(content) def main(): # Get all HTML files in the current directory html_files = [f for f in os.listdir('.') if f.endswith('.html')] for html_file in html_files: print(f'Updating {html_file}...') update_file_links(html_file) if __name__ == '__main__': main()