Si le répertoire source n'existe pas, on le créé en local

This commit is contained in:
Alex 2024-03-19 20:19:51 +01:00
parent 49f411eed3
commit 84a34dafa7
2 changed files with 12 additions and 7 deletions

View File

@ -1,4 +1,4 @@
{
"filigrame": "Le nom de l'agence",
"source_directory": "H:\\Repertoire\\contenant les documents a taguer"
"filigrame": "Le nom de l'agence",
"source_directory": "C:\\Directory\\with\\Oriiginal\\Files"
}

15
main.py
View File

@ -147,15 +147,20 @@ def open_in_file_explorer(directory):
def create_original_files_directory():
config = load_config()
original_files_directory = config.get("source_directory", "Original Files")
if not os.path.exists(original_files_directory):
os.makedirs(original_files_directory)
print(f"Répertoire Original Files créé à l'emplacement : {os.path.abspath(original_files_directory)}")
original_files_directory = config.get("source_directory")
if os.path.isdir(original_files_directory):
return
else:
temp_directory = os.path.join(os.getcwd(), f"Original_Files")
os.makedirs(temp_directory)
print(f"Répertoire de travail créé à l'emplacement : {temp_directory}")
# Mettre à jour le chemin du répertoire dans le fichier de configuration
config["source_directory"] = original_files_directory
config["source_directory"] = temp_directory
with open("config.json", "w") as f:
json.dump(config, f, indent=4)
print(f"Sauvegarde de la configuration")
if __name__ == '__main__':
# Creation du répertoire soruces pour mettre les documents