diff --git a/config.json b/config.json index 9a09983..b79cb4b 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,5 @@ { - "filigrame": "Le nom de l'agence", - "source_directory": "C:\\Directory\\with\\Oriiginal\\Files" + "filigrame": "Agence la foret", + "zipfile": "I:\\Drive\\Documents\\Logement Maelis", + "source_directory": "H:\\Utilisateurs\\Alex\\Maelis\\Maelis - Logement 2024" } \ No newline at end of file diff --git a/main.py b/main.py index d0e2fd1..dda6e47 100644 --- a/main.py +++ b/main.py @@ -16,7 +16,7 @@ Il est conseillé de mettre un chemin absolu. # Press Maj+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. -import os, json, subprocess +import os, json, subprocess, zipfile from PIL import Image, ImageDraw, ImageFont import piexif from pdf2image import convert_from_path @@ -161,7 +161,15 @@ def create_original_files_directory(): with open("config.json", "w") as f: json.dump(config, f, indent=4) print(f"Sauvegarde de la configuration") - + + +def zip_directory(directory, zip_file): + with zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) as zipf: + for root, _, files in os.walk(directory): + for file in files: + file_path = os.path.join(root, file) + zipf.write(file_path, os.path.relpath(file_path, directory)) + if __name__ == '__main__': # Creation du répertoire soruces pour mettre les documents create_original_files_directory() @@ -187,3 +195,8 @@ if __name__ == '__main__': # Ouverture du répertoire contenant toutes les images tagées open_in_file_explorer(destination_directory) + + # Compression du répertoire + fichierZip = os.path.join(config["zipfile"], text.replace(" ", "_") + ".zip") + print("Compression du répertoire et sauvegarde dans ", fichierZip) + zip_directory(destination_directory, fichierZip) diff --git a/requirements.txt b/requirements.txt index 46523ed..37d3755 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ Pillow>=8.4.0 piexif -pdf2image \ No newline at end of file +pdf2image +zipfile \ No newline at end of file