diff options
-rw-r--r-- | removeNullCharacters.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/removeNullCharacters.py b/removeNullCharacters.py new file mode 100644 index 00000000..bd7d0a95 --- /dev/null +++ b/removeNullCharacters.py @@ -0,0 +1,24 @@ +import os +import glob + +def remove_null_characters_from_html(directory, ignore_files=[], ignore_directories=[]): + html_files = glob.glob(os.path.join(directory, '**/*.html'), recursive=True) + + for file_path in html_files: + # ファイルやディレクトリが対象外の場合はスキップ + if os.path.basename(file_path) in ignore_files or os.path.dirname(file_path) in ignore_directories: + continue + + with open(file_path, 'r', encoding='utf-8') as file: + content = file.read() + + content = content.replace('\0', '') # null文字を削除 + + with open(file_path, 'w', encoding='utf-8') as file: + file.write(content) + +if __name__ == "__main__": + target_directory = "./build" + ignore_files = ["404.html"] + ignore_directories = ["assets", "img", ] + remove_null_characters_from_html(target_directory, ignore_files, ignore_directories)
\ No newline at end of file |