diff --git a/generate_html.py b/generate_html.py index a598a04..a00e5af 100755 --- a/generate_html.py +++ b/generate_html.py @@ -196,8 +196,6 @@ def listfolder(folder: str, title: str): image += f': RAW' image += "" images.extend([image]) - if os.path.exists(os.path.join(folder, "index.html")): - os.remove(os.path.join(folder, "index.html")) if len(images) > 0 or (args.fancyfolders and not contains_files): with open(os.path.join(folder, "index.html"), "w", encoding="utf-8") as f: f.write(temp_obj.substitute(title=title)) @@ -209,15 +207,18 @@ def listfolder(folder: str, title: str): f.write("\n") f.write(" \n") f.write(" \n") - f.write('
\n') - for chunk in np.array_split(images, 8): - f.write('
\n') - for image in chunk: - f.write(f" {image}\n") - f.write("
\n") - f.write("
\n") + if len(images) > 0: + f.write('
\n') + for chunk in np.array_split(images, 8): + f.write('
\n') + for image in chunk: + f.write(f" {image}\n") + f.write("
\n") + f.write("
\n") f.write(" \n") f.close() + else: + os.remove(os.path.join(folder, "index.html")) pbar.update(1)