From 9140c07feb28420601471d6269bcf630021e2f81 Mon Sep 17 00:00:00 2001 From: KnugiHK <24708955+KnugiHK@users.noreply.github.com> Date: Tue, 28 Dec 2021 20:04:40 +0800 Subject: [PATCH] Prevent PermissionError from raising --- Whatsapp_Chat_Exporter/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Whatsapp_Chat_Exporter/__main__.py b/Whatsapp_Chat_Exporter/__main__.py index 47b3b97..68dc512 100644 --- a/Whatsapp_Chat_Exporter/__main__.py +++ b/Whatsapp_Chat_Exporter/__main__.py @@ -150,7 +150,10 @@ def main(): create_html(data, options.output, options.template) if not os.path.isdir(f"{options.output}/{options.media}"): - shutil.move(options.media, f"{options.output}/") + try: + shutil.move(options.media, f"{options.output}/") + except PermissionError: + print(f"Cannot remove original WhatsApp directory. Perhaps the directory is opened?") if options.json: with open("result.json", "w") as f: