import os
import shutil
folder_path = '/www/wwwroot'
source_404_file ='/www/source_404.html'
def check_and_copy_404_file(folder_path, source_404_file):
subfolders = [f for f in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, f))]
for subfolder in subfolders:
target_path = os.path.join(folder_path, subfolder, '404.html')
shutil.copy(source_404_file, target_path)
check_and_copy_404_file(folder_path, source_404_file)
批量替换/www/wwwroot文件夹下的1级文件夹下的404.html,适合宝塔护卫神等统一文件夹规律的