From 5060490ac49212df581418179a5e04827f9bda95 Mon Sep 17 00:00:00 2001 From: Ambulance Clerc Date: Wed, 1 Mar 2023 18:55:34 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20script=20pour=20compter=20les=20?= =?UTF-8?q?caract=C3=A8res=20du=20projet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- counter.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 counter.py diff --git a/counter.py b/counter.py new file mode 100644 index 0000000..c442fb0 --- /dev/null +++ b/counter.py @@ -0,0 +1,16 @@ +import os + +def count_chars_in_folder(folder_path): + total_chars = 0 + for filename in os.listdir(folder_path): + filepath = os.path.join(folder_path, filename) + if os.path.isfile(filepath): + with open(filepath, 'r') as file: + content = file.read() + total_chars += len(content) + print(f"fichier {filepath} = { len(content)}") + return total_chars + +folder_path = '.' # mettre le chemin absolu vers le dossier ici +total_chars = count_chars_in_folder(folder_path) +print(f"Le nombre total de caractères dans les fichiers du dossier {folder_path} est : {total_chars}") \ No newline at end of file