diff --git a/tools/diff.sh b/tools/diff.sh new file mode 100644 index 0000000..92b0515 --- /dev/null +++ b/tools/diff.sh @@ -0,0 +1,88 @@ +process_files() { + for file in "$1"/*; do + if [ -d "$file" ]; then + # 如果是目录,则递归调用函数 + process_files "$file" + elif [ -f "$file" ]; then + # 如果是文件,检查是否为文本文件 + if [[ $file == *.txt ]]; then + echo "$file is a text file." + # '{' 和 '}' + # original_tag = xxx + sed -i 's/original_tag = ENG/original_tag = HUJ/g' "$file" + sed -i 's/original_tag = USA/original_tag = BYG/g' "$file" + sed -i 's/original_tag = CHI/original_tag = DOH/g' "$file" + sed -i 's/original_tag = PRC/original_tag = DOH/g' "$file" + sed -i 's/original_tag = SOV/original_tag = BFL/g' "$file" + sed -i 's/original_tag = GER/original_tag = TIX/g' "$file" + sed -i 's/original_tag = FRA/original_tag = YUW/g' "$file" + sed -i 's/original_tag = JAP/original_tag = CHY/g' "$file" + sed -i 's/original_tag = ITA/original_tag = SAD/g' "$file" + # has_war_with = xxx + sed -i 's/has_war_with = ENG/has_war_with = HUJ/g' "$file" + sed -i 's/has_war_with = USA/has_war_with = BYG/g' "$file" + sed -i 's/has_war_with = CHI/has_war_with = DOH/g' "$file" + sed -i 's/has_war_with = PRC/has_war_with = DOH/g' "$file" + sed -i 's/has_war_with = SOV/has_war_with = BFL/g' "$file" + sed -i 's/has_war_with = GER/has_war_with = TIX/g' "$file" + sed -i 's/has_war_with = FRA/has_war_with = YUW/g' "$file" + sed -i 's/has_war_with = JAP/has_war_with = CHY/g' "$file" + sed -i 's/has_war_with = ITA/has_war_with = SAD/g' "$file" + # tag = xxx + sed -i 's/tag = ENG/tag = HUJ/g' "$file" + sed -i 's/tag = USA/tag = BYG/g' "$file" + sed -i 's/tag = CHI/tag = DOH/g' "$file" + sed -i 's/tag = PRC/tag = DOH/g' "$file" + sed -i 's/tag = SOV/tag = BFL/g' "$file" + sed -i 's/tag = GER/tag = TIX/g' "$file" + sed -i 's/tag = FRA/tag = YUW/g' "$file" + sed -i 's/tag = JAP/tag = CHY/g' "$file" + sed -i 's/tag = ITA/tag = SAD/g' "$file" + # TAG = xxx + sed -i 's/TAG = ENG/tag = HUJ/g' "$file" + sed -i 's/TAG = USA/tag = BYG/g' "$file" + sed -i 's/TAG = CHI/tag = DOH/g' "$file" + sed -i 's/TAG = PRC/tag = DOH/g' "$file" + sed -i 's/TAG = SOV/tag = BFL/g' "$file" + sed -i 's/TAG = GER/tag = TIX/g' "$file" + sed -i 's/TAG = FRA/tag = YUW/g' "$file" + sed -i 's/TAG = JAP/tag = CHY/g' "$file" + sed -i 's/TAG = ITA/tag = SAD/g' "$file" + # other = xxx + sed -i 's/other = ENG/other = HUJ/g' "$file" + sed -i 's/other = USA/other = BYG/g' "$file" + sed -i 's/other = CHI/other = DOH/g' "$file" + sed -i 's/other = PRC/other = DOH/g' "$file" + sed -i 's/other = SOV/other = BFL/g' "$file" + sed -i 's/other = GER/other = TIX/g' "$file" + sed -i 's/other = FRA/other = YUW/g' "$file" + sed -i 's/other = JAP/other = CHY/g' "$file" + sed -i 's/other = ITA/other = SAD/g' "$file" + # is_ally_with = xxx + sed -i 's/is_ally_with = ENG/is_ally_with = HUJ/g' "$file" + sed -i 's/is_ally_with = USA/is_ally_with = BYG/g' "$file" + sed -i 's/is_ally_with = CHI/is_ally_with = DOH/g' "$file" + sed -i 's/is_ally_with = PRC/is_ally_with = DOH/g' "$file" + sed -i 's/is_ally_with = SOV/is_ally_with = BFL/g' "$file" + sed -i 's/is_ally_with = GER/is_ally_with = TIX/g' "$file" + sed -i 's/is_ally_with = FRA/is_ally_with = YUW/g' "$file" + sed -i 's/is_ally_with = JAP/is_ally_with = CHY/g' "$file" + sed -i 's/is_ally_with = ITA/is_ally_with = SAD/g' "$file" + # Others 1 + sed -i -E 's/(^|[[:space:]]|\{|})ENG($|[[:space:]]|\{|})/\1HUJ\2/g' "$file" + sed -i -E 's/(^|[[:space:]]|\{|})USA($|[[:space:]]|\{|})/\1BYG\2/g' "$file" + # sed -i -E 's/(^|[[:space:]]|\{|})CHI($|[[:space:]]|\{|})/\1DOH\2/g' "$file" + sed -i -E 's/(^|[[:space:]]|\{|})PRC($|[[:space:]]|\{|})/\1DOH\2/g' "$file" + sed -i -E 's/(^|[[:space:]]|\{|})SOV($|[[:space:]]|\{|})/\1HUJ\2/g' "$file" + sed -i -E 's/(^|[[:space:]]|\{|})GER($|[[:space:]]|\{|})/\1HUJ\2/g' "$file" + sed -i -E 's/(^|[[:space:]]|\{|})FRA($|[[:space:]]|\{|})/\1HUJ\2/g' "$file" + sed -i -E 's/(^|[[:space:]]|\{|})JAP($|[[:space:]]|\{|})/\1HUJ\2/g' "$file" + sed -i -E 's/(^|[[:space:]]|\{|})ITA($|[[:space:]]|\{|})/\1HUJ\2/g' "$file" + fi + fi + done +} + +# 调用函数,从指定目录开始 +process_files src +