SCRIPT_PATH=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
OUTPUT_FOLDER="${SCRIPT_DIR}/输出文件"
LOADINGBG_FOLDER="/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/ImageDownloadV3/LoadingBG"
TARGET_ALL=(
    "139f7ca4602884c210afd4193459d03b" "33b643f557f43d5b254340100d981d10" "350eef5300f19b90cb99babf6d97b038"
    "6800fb237e5eb16cd726bb9201b07051" "6f1f2da5655591f3e414f9cb2f637364" "8450181c81be27e448abc8b2eb24b49b"
    "9bb41bcd562fb5e08f8efbf064957d60" "d1f95cf4b3f8990d8b0444575a1fbb61" "dc9de740a5e4939f041c7c33fe6e5abd"
    "2b3ee26822e44e9ee5fae90181d534d3" "33d6d44faa806c43197c2a92aabc7460" "59f95ac8c3555e4af9ef92cd881f0612"
    "6e0156c739f31797a89122c009afb3fb" "711e059443369ce055b46dc56f9cf40a" "864f05443816f3c3f9aa9b0fdceb7f38"
    "a26516845498fc100bbc825b7b68af7c" "bdb5cb02a2256317c81129c65d9e417b" "de97370724f88a85edd5866d2c3182c3"
    "ffc29f7b097133e8f3d39ee61269cb91" "1307d8cb164b1716150b1193661d419e" "43c0dd62e8ff2873ab30390dfff69bec"
    "453adf21a45ebd52f922bae31adfb2ce" "68db71d6258d3baed1064cb9d26dabe8" "712a425e67ea455e5c0e1a010f2beed2"
    "8aefdd285ef0b319c6c654cebe042c00" "984c5a0871c77b4be3f35e50b5562169" "a7cda6b5093f2ed4432a65fdfc1e3ae8"
    "df257341f217aa7c08d73cc0f0c1ee6d" "fc97d5aec6ecb8150a455e5c0e1a010f2beed2" "fdbf63af94954971ad1fea90533664d8"
    "08c12c2475fff37179438cc4f325f08f" "28c4eae03701eb484686d5b1d4f9c0e8" "368d5e16e8498530a4551a883b4d532d"
    "52a710e8c12b81f03f91b32a49e4b587" "685aacc44cfa18a28d38c4a07cbc1c9a" "7319d40ff352f0f743fb0337253366c3"
    "90c97b7b09f2921ba967bdac17e0633e" "a978a939e073614558b000d814a847a2" "e28867b2c4fd1f02db9d61427d8284ab"
    "3d0669e39a72cbcaffbf11e15e62c4ce" "461f2f063269ccd64880179ae909bd37" "4e014cdb4f6c86fb58fb53f03bf4a51b"
    "75a9e7dc45a1a4923e414cdb4f6c86fb" "8f399605f7eaefc627b4ad657686403d" "919bfd8d9c899b8ccbeec86f25435864"
    "ae33b94972013f4dcaf978c9f2df79c5" "eb0529ed435d48cada1e8ccd524688a4" "0ba735da8cdf5051002edf4e081f4dac"
    "15af1123e6120451c93ddd34eb6f9568" "252418a57d99663ca1e3a88b74e583e7" "77fe6105888e1c96f2cae3eae8394140"
    "987c58e6d4ce229193e7c8664ef66ad9" "a67bcfa3f48e06d8f37206b57fbf85f9" "b91ada8a1edb5fc4351f6943e23f95d1"
    "e56bcefea38cb6bae624bbeedbef6a01" "ed7decac5bd9bf7f527508b4e52d95d2" "7e2deab32ce95d434b42639c74fdba12"
    "9a1a58aaf8002720b19a4cc5cecf28e0" "b99fb15b059585b2e437ff5b3690a676" "fc85adec013f896f21544c549fb35960"
    "059b9b9068b8d0d806a5e134fff970ce"
)
auto_check_permission() {
    if [ "$(id -u)" -eq 0 ]; then
echo -e "\033[32m当前为root权限执行\033[0m"
        return 0
    else
echo -e "\033[32m当前为no root权限执行\033[0m"
        return 1
    fi
}
root_auto_copy() {
    echo -e "\n\033[34m📂 开始 Root 模式自动处理...\033[0m"
    if [ ! -d "$LOADINGBG_FOLDER" ]; then
        mkdir -p "$LOADINGBG_FOLDER"
        if [ $? -eq 0 ]; then
            echo -e "\033[32m✅ 已创建 LoadingBG 目录\033[0m"
        else
            echo -e "\033[31m❌ 创建目录失败，请检查 Root 权限\033[0m"
            exit 1
        fi
    fi
    rm -rf "${LOADINGBG_FOLDER}/"*
    cp -f "${OUTPUT_FOLDER}/"* "$LOADINGBG_FOLDER/"
    if [ $? -eq 0 ]; then
        echo -e "\033[32m✅ 已自动完成文件替换（Root 模式）\033[0m"
    else
        echo -e "\033[31m❌ 文件复制失败，请重试\033[0m"
    fi
}
no_root_manual_hint() {
    echo -e "\n\033[34m📋 No Root 模式 - 手动操作提示\033[0m"
    echo -e "1. 打开 MT 管理器，授予「访问所有文件」权限"
    echo -e "2. 找到生成文件目录：\033[32m${OUTPUT_FOLDER}\033[0m"
    echo -e "3. 全选文件，复制到目标目录：\033[32m${LOADINGBG_FOLDER}\033[0m"
    echo -e "4. 覆盖原有文件即可完成替换"
}
enter_confirm() {
    echo -n "是否确认使用该文件进行替换？按回车键确定（直接回车继续）："
    read -r confirm
    echo
}
batch_modify() {
    clear
    SOURCE_FILE1="${SCRIPT_DIR}/1"
    SOURCE_FILE2="${SCRIPT_DIR}/2"
    SOURCE_FILE3="${SCRIPT_DIR}/3"
    SOURCE_FILE4="${SCRIPT_DIR}/4"
    SOURCE_FILE5="${SCRIPT_DIR}/5"
    SOURCE_FILE6="${SCRIPT_DIR}/6"
    mkdir -p "$OUTPUT_FOLDER"
    rm -rf "${OUTPUT_FOLDER:?}"/* 2>/dev/null
    echo -e "\033[32m✅ 输出目录准备就绪：$OUTPUT_FOLDER（已清空原有内容）\033[0m"
    echo -e "\n📌 请选择要使用的图片文件数量（1-7个，文件1-6需与脚本同目录）："
    echo -e "[1] 1个文件（1生成全部61个目标文件）"
    echo -e "[2] 2个文件（1、2各生成30个，剩余1个随机）"
    echo -e "[3] 3个文件（1、2、3各生成20个，剩余1个随机）"
    echo -e "[4] 4个文件（1、2、3、4各生成15个，剩余1个随机）"
    echo -e "[5] 5个文件（1、2、3、4、5各生成12个，剩余1个随机）"
    echo -e "[6] 6个文件（1、2、3、4、5、6各生成10个，剩余1个随机）"
    echo -e "[7] 自定义文件（通过搜索/指定路径选择多个文件）"
    echo -n "输入数字1-7选择："
    read -r file_count
    if ! echo "$file_count" | grep -qE '^[1-7]$'; then
        echo -e "\n\033[31m❌ 选择错误！仅支持输入1-7的数字，脚本退出。\033[0m"
        exit 1
    fi
    SOURCE_ARRAY=()
    missing_files=""
    if [ "$file_count" -ne 7 ]; then
        i=1
        while [ "$i" -le "$file_count" ]; do
            source_path="SOURCE_FILE$i"
            eval "current_src=\${$source_path}"
            if [ ! -f "$current_src" ]; then
                missing_files="${missing_files} $i"
            else
                SOURCE_ARRAY+=("$current_src")
            fi
            i=$((i + 1))
        done
        if [ -n "$missing_files" ]; then
            echo -e "\n\033[31m❌ 错误：缺少文件：${missing_files:1}（需与脚本同目录）\033[0m"
            exit 1
        fi
        echo -e "\n\033[32m✅ 已检测到$file_count个源文件（1-$file_count），均在脚本同目录，可用\033[0m"
        enter_confirm
    else
        clear
        echo -e "📌 请选择文件获取方式：                            [1] 精准搜索（完全匹配文件名，排除输出文件）       [2] 模糊搜索（文件名包含关键词，排除输出文件）"
        echo -e "[3] 指定路径（直接输入图片完整路径）"
        echo -n "请输入选项编号："
        read -r custom_mode
        if ! echo "$custom_mode" | grep -qE '^[1-3]$'; then
            echo -e "\n\033[31m❌ 选项错误！仅支持输入1、2、3，脚本退出。\033[0m"
            exit 1
        fi
        case "$custom_mode" in
            1)
                echo -n "请输入搜索关键词："
                read -r keyword
                echo
                temp_file="${SCRIPT_DIR}/.tmp_search_custom"
                rm -f "$temp_file" 2>/dev/null
                find "$SCRIPT_DIR" -maxdepth 10 -type f -name "$keyword" ! -path "${OUTPUT_FOLDER}/*" -print0 | tr -d '\r' | xargs -0 echo > "$temp_file"
                unset file_paths
                file_paths=()
                while IFS= read -r -d '' path; do
                    path_trim=$(echo "$path" | xargs)
                    [ -n "$path_trim" ] && file_paths+=("$path_trim")
                done < <(tr '\n' '\0' < "$temp_file")
                rm -f "$temp_file" 2>/dev/null
                if [ ${#file_paths[@]} -eq 0 ]; then
                    echo -e "\n\033[31m❌ 未找到匹配文件，脚本退出。\033[0m"
                    exit 1
                fi
                SOURCE_ARRAY=("${file_paths[@]}")
                ;;
            2)
                echo -n "请输入搜索关键词："
                read -r keyword
                echo
                temp_file="${SCRIPT_DIR}/.tmp_search_custom"
                rm -f "$temp_file" 2>/dev/null
                find "$SCRIPT_DIR" -maxdepth 10 -type f -name "*${keyword}*" ! -path "${OUTPUT_FOLDER}/*" -print0 | tr -d '\r' | xargs -0 echo > "$temp_file"
                unset file_paths
                file_paths=()
                while IFS= read -r -d '' path; do
                    path_trim=$(echo "$path" | xargs)
                    [ -n "$path_trim" ] && file_paths+=("$path_trim")
                done < <(tr '\n' '\0' < "$temp_file")
                rm -f "$temp_file" 2>/dev/null
                if [ ${#file_paths[@]} -eq 0 ]; then
                    echo -e "\n\033[31m❌ 未搜索到符合条件的文件，脚本退出。\033[0m"
                    exit 1
                fi
                echo -e "\n\033[32m✅ 搜索到${#file_paths[@]}个符合条件的文件，请选择（序号用空格隔开）：\033[0m"
                for ((i=0; i<${#file_paths[@]}; i++)); do
                    echo -e "[$((i+1))] ${file_paths[$i]}"
                done
                echo -n "输入选择的序号："
                read -r -a choice_nums
               if [ ${#choice_nums[@]} -eq 0 ]; then
                    echo -e "\n\033[31m❌ 未选择文件，脚本退出。\033[0m"
                    exit 1
                fi
                for num in "${choice_nums[@]}"; do
                    if ! echo "$num" | grep -qE '^[0-9]+$' || [ "$num" -lt 1 ] || [ "$num" -gt ${#file_paths[@]} ]; then
                        echo -e "\n\033[33m⚠️  序号$num无效，跳过该序号\033[0m"
                    else
                        SOURCE_ARRAY+=("${file_paths[$((num-1))]}")
                        echo -e "\033[32m✅ 选中文件：${file_paths[$((num-1))]}\033[0m"
                    fi
                done
                ;;
            3)
                echo -n "请输入多个文件完整路径（用空格隔开）："
                read -r -a custom_paths
                echo
                if [ ${#custom_paths[@]} -eq 0 ]; then
                    echo -e "\n\033[31m❌ 未输入文件路径，脚本退出。\033[0m"
                    exit 1
                fi
                for path in "${custom_paths[@]}"; do
                    if command -v readlink &>/dev/null; then
                        real_path=$(readlink -f "$path")
                    else
                        if [ "${path:0:1}" != "/" ]; then
                            real_path="${SCRIPT_DIR}/${path}"
                        else
                            real_path="$path"
                        fi
                    fi
                    if [ -f "$real_path" ] && [ -r "$real_path" ]; then
                        SOURCE_ARRAY+=("$real_path")
                        echo -e "\033[32m✅ 路径有效，添加文件：$real_path\033[0m"
                    else
                        echo -e "\n\033[31m❌ 路径无效，跳过该路径：$path\033[0m"
                    fi
                done
                ;;
        esac
        if [ ${#file_paths[@]} -eq 1 ]; then
            echo -e "\n✅ 搜索到文件，路径：${file_paths[0]}"
        fi
        enter_confirm
        if [ ${#SOURCE_ARRAY[@]} -eq 0 ]; then
            echo -e "\n\033[31m❌ 未获取到有效源文件，脚本退出。\033[0m"
            exit 1
        fi
        file_count=${#SOURCE_ARRAY[@]}
        echo -e "\n\033[32m✅ 自定义文件选择完成，共获取到$file_count个有效源文件\033[0m"
    fi
    total_target=61
    fixed_count=$((total_target / file_count))
    remaining_count=$((total_target - fixed_count * file_count))
    echo -e "\n📋 分配规则："
    echo -e "→ 共生成$total_target个目标文件，使用$file_count个源文件"
    echo -e "→ 每个源文件固定生成$fixed_count个，剩余$remaining_count个随机从$file_count个源文件中选择"
    remaining_targets=("${TARGET_ALL[@]:$((fixed_count * file_count)):$remaining_count}")
    echo -e "→ 随机分配的目标文件：\033[34m${remaining_targets[*]}\033[0m"
    success_total=0
    fail_files=()
    current_target_idx=0
    i=0
    while [ "$i" -lt "$file_count" ]; do
        current_source="${SOURCE_ARRAY[$i]}"
        echo -e "\n🚀 正在处理源文件$((i+1))：$current_source（生成$fixed_count个目标文件）"
                j=0
        while [ "$j" -lt "$fixed_count" ]; do
            target_name="${TARGET_ALL[$current_target_idx]}"
            target_path="${OUTPUT_FOLDER}/${target_name}"
            cp -f "$current_source" "$target_path" 2>/dev/null
            if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$current_source" "$target_path" 2>/dev/null; fi
            if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$current_source" "$target_path" 2>/dev/null; fi
            if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$current_source" "$target_path" 2>/dev/null; fi
            if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$current_source" "$target_path" 2>/dev/null; fi
            if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$current_source" "$target_path" 2>/dev/null; fi
            if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$current_source" "$target_path" 2>/dev/null; fi
            if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$current_source" "$target_path" 2>/dev/null; fi
                      if [ -f "$target_path" ]; then
                success_total=$((success_total + 1))
                echo -e "\033[32m✅ 成功：源文件$((i+1)) → $target_name\033[0m"
            else
                fail_files+=("$target_name")
                echo -e "\033[31m❌ 失败：源文件$((i+1)) → $target_name\033[0m"
            fi
            current_target_idx=$((current_target_idx + 1))
            j=$((j + 1))
        done
              i=$((i + 1))
    done
    echo -e "\n🚀 正在随机分配剩余$remaining_count个目标文件"
    for ((k=0; k<remaining_count; k++)); do
        random_source_idx=$((RANDOM % file_count))
        random_source="${SOURCE_ARRAY[$random_source_idx]}"
        random_target="${remaining_targets[$k]}"
        random_target_path="${OUTPUT_FOLDER}/${random_target}"
        cp -f "$random_source" "$random_target_path" 2>/dev/null
        if [ ! -f "$random_target_path" ]; then sleep 0.3 && cp -f "$random_source" "$random_target_path" 2>/dev/null; fi
        if [ ! -f "$random_target_path" ]; then sleep 0.3 && cp -f "$random_source" "$random_target_path" 2>/dev/null; fi
        if [ ! -f "$random_target_path" ]; then sleep 0.3 && cp -f "$random_source" "$random_target_path" 2>/dev/null; fi
        if [ ! -f "$random_target_path" ]; then sleep 0.3 && cp -f "$random_source" "$random_target_path" 2>/dev/null; fi
        if [ ! -f "$random_target_path" ]; then sleep 0.3 && cp -f "$random_source" "$random_target_path" 2>/dev/null; fi
        if [ ! -f "$random_target_path" ]; then sleep 0.3 && cp -f "$random_source" "$random_target_path" 2>/dev/null; fi
        if [ ! -f "$random_target_path" ]; then sleep 0.3 && cp -f "$random_source" "$random_target_path" 2>/dev/null; fi
               if [ -f "$random_target_path" ]; then
            success_total=$((success_total + 1))
            echo -e "\033[32m✅ 随机成功：源文件$((random_source_idx+1)) → $random_target\033[0m"
        else
            fail_files+=("$random_target")
            echo -e "\033[31m❌ 随机失败：源文件$((random_source_idx+1)) → $random_target\033[0m"
        fi
    done
    echo -e "\n🎉 批量生成完成！"
    echo -e "\033[32m✅ 成功生成：$success_total 个文件（共需生成$total_target个）\033[0m"
    echo -e "\033[31m❌ 生成失败：${#fail_files[@]} 个文件\033[0m"
    if [ ${#fail_files[@]} -gt 0 ]; then
        echo -e "\n❌ 失败文件列表：\033[31m${fail_files[*]}\033[0m"
    else
        echo -e "\n✅ 无失败文件，全部生成成功！\033[0m"
    fi
    echo -e "\n📌 生成文件存放目录：$OUTPUT_FOLDER\033[0m"
     if auto_check_permission; then
        root_auto_copy
    else
        no_root_manual_hint
    fi
}
search_files() {
    local search_mode=$1
    local keyword=$2
    local script_dir=$3
    local output_dir=$4
    local temp_file="${script_dir}/.tmp_search_custom"
    rm -f "$temp_file" 2>/dev/null
    if [ "$search_mode" -eq 1 ]; then
        find "$script_dir" -maxdepth 10 -type f -name "$keyword" ! -path "${output_dir}/*" -print0 | tr -d '\r' | xargs -0 echo > "$temp_file"
    elif [ "$search_mode" -eq 2 ]; then
        find "$script_dir" -maxdepth 10 -type f -name "*${keyword}*" ! -path "${output_dir}/*" -print0 | tr -d '\r' | xargs -0 echo > "$temp_file"
    fi
    unset file_paths
    file_paths=()
    while IFS= read -r -d '' path; do
        path_trim=$(echo "$path" | xargs)
        [ -n "$path_trim" ] && file_paths+=("$path_trim")
    done < <(tr '\n' '\0' < "$temp_file")
    rm -f "$temp_file" 2>/dev/null

    export file_paths
}
check_custom_path() {
    local input_path=$1
    if command -v readlink &>/dev/null; then
        real_path=$(readlink -f "$input_path")
    else
        if [ "${input_path:0:1}" != "/" ]; then
            real_path="${SCRIPT_DIR}/${input_path}"
        else
            real_path="$input_path"
        fi
    fi
    if [ -f "$real_path" ] && [ -r "$real_path" ]; then
        echo "$real_path"
        return 0
    else
        return 1
    fi
}
single_modify() {
    clear
    echo -e "📌 请选择文件获取方式：                            [1] 精准搜索（完全匹配文件名，排除输出文件）       [2] 模糊搜索（文件名包含关键词，排除输出文件）"
    echo -e "[3] 指定路径（直接输入图片完整路径）"
    echo -n "请输入选项编号："
    read -r file_mode
    input_path=""
    case "$file_mode" in
        1|2)
            echo -n "请输入搜索关键词："
            read -r keyword
            echo
            search_files "$file_mode" "$keyword" "$SCRIPT_DIR" "$OUTPUT_FOLDER"
             if [ ${#file_paths[@]} -eq 0 ]; then
                echo -e "\n\033[31m❌ 未搜索到符合条件的文件，脚本退出。\033[0m"
                exit 1
            fi
            if [ ${#file_paths[@]} -eq 1 ]; then
                input_path="${file_paths[0]}"
                echo -e "✅ 搜索到文件，路径：$input_path"
            else
                echo -e "\n\033[32m✅ 搜索到${#file_paths[@]}个符合条件的文件，请选择：\033[0m"
                for ((i=0; i<${#file_paths[@]}; i++)); do
                    echo -e "[$((i+1))] ${file_paths[$i]}"
                done
                echo -n "输入选择的序号："
                read -r choice_num
                if ! echo "$choice_num" | grep -qE '^[0-9]+$' || [ "$choice_num" -lt 1 ] || [ "$choice_num" -gt ${#file_paths[@]} ]; then
                    echo -e "\n\033[31m❌ 选项错误！脚本退出。\033[0m"
                    exit 1
                fi
                input_path="${file_paths[$((choice_num-1))]}"
                echo -e "\n✅ 搜索到文件，路径：$input_path"
            fi
            ;;
        3)
            echo -n "请输入图片完整路径（支持绝对/相对路径）："
            read -r custom_path
            echo
            valid_path=$(check_custom_path "$custom_path")
            if [ $? -eq 0 ] && [ -n "$valid_path" ]; then
                input_path="$valid_path"
                echo -e "✅ 搜索到文件，路径：$input_path"
            else
                echo -e "\n\033[31m❌ 路径无效！请检查路径是否正确、文件是否存在且可读，脚本退出。\033[0m"
                exit 1
            fi
            ;;
        *)
            echo -e "\n\033[31m❌ 选项错误！仅支持输入1、2、3，脚本退出。\033[0m"
            exit 1
            ;;
    esac
    enter_confirm
    mkdir -p "$OUTPUT_FOLDER"
    rm -rf "${OUTPUT_FOLDER:?}"/* 2>/dev/null
    success_total=0
    fail_files=()
    total_target=${#TARGET_ALL[@]}
    echo -e "\n🚀 正在批量替换所有目标文件（共$total_target个）..."
    for target_name in "${TARGET_ALL[@]}"; do
        target_path="${OUTPUT_FOLDER}/${target_name}"
        cp -f "$input_path" "$target_path" 2>/dev/null
        if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$input_path" "$target_path" 2>/dev/null; fi
        if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$input_path" "$target_path" 2>/dev/null; fi
        if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$input_path" "$target_path" 2>/dev/null; fi
        if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$input_path" "$target_path" 2>/dev/null; fi
        if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$input_path" "$target_path" 2>/dev/null; fi
        if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$input_path" "$target_path" 2>/dev/null; fi
        if [ ! -f "$target_path" ]; then sleep 0.3 && cp -f "$input_path" "$target_path" 2>/dev/null; fi
        if [ -f "$target_path" ]; then
            success_total=$((success_total + 1))
            echo -e "\033[32m✅ 成功：$target_name\033[0m"
        else
            fail_files+=("$target_name")
            echo -e "\033[31m❌ 失败：$target_name\033[0m"
        fi
    done
    echo -e "\n🎉 单文件修改完成！"
    echo -e "\033[32m✅ 成功替换：$success_total 个文件（共需生成$total_target个）\033[0m"
    echo -e "\033[31m❌ 生成失败：${#fail_files[@]} 个文件\033[0m"
    if [ ${#fail_files[@]} -gt 0 ]; then
        echo -e "\n❌ 失败文件列表：\033[31m${fail_files[*]}\033[0m"
    else
        echo -e "\n✅ 无失败文件，全部生成成功！\033[0m"
    fi
    echo -e "\n📌 生成文件存放目录：$OUTPUT_FOLDER\033[0m"
    if auto_check_permission; then
        root_auto_copy
    else
        no_root_manual_hint
    fi
}
clear
echo "==================== 和平加载图一键替换工具 ===================="
auto_check_permission
echo "[1] 批量多文件修改（使用1-6个源文件均分替换61个目标文件，新增自定义文件）"
echo "[2] 单文件修改（支持精准/模糊搜索+指定路径，自动排除输出文件）"
echo -n "请输入选项编号（1/2）："
read -r choice
case "$choice" in
    1) batch_modify ;;
    2) single_modify ;;
    *) echo -e "\n\033[31m❌ 选项错误！仅支持输入1或2，脚本退出。\033[0m" && exit 1 ;;
esac
echo -e "\n📌 操作全部完成！按回车键关闭终端..."
read -r
exit 0