diff --git a/README.md b/README.md index c4a9df5..ff3f855 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,6 @@ myvenv/bin/activate pip install -r requirements.txt ``` -Take a look at the configuration section inside the script and then launch it. +Take a look at the configuration section inside the script and then launch it. + +The script will create all destination folders, sort the pictures, and delete empty destination folders in the end. diff --git a/sizer.py b/sizer.py index 5795875..2b9906b 100755 --- a/sizer.py +++ b/sizer.py @@ -18,6 +18,13 @@ def pics_list(path:os.path): def file_move(file, dest): shutil.move(file, dest) +def delete_empty_folders(rootdir): + folders = [f.path for f in os.scandir(rootdir) if f.is_dir()] + for folder in folders: + if not os.listdir(folder): + print(f"{folder} is empty and will be deleted") + os.rmdir(folder) + def main(): #------------------ CONFIG START @@ -100,6 +107,8 @@ def main(): dest_folder = foldersd print(f"{f} moved to {rootdir}{dest_folder}") + delete_empty_folders(rootdir) + print("Done, Sayonara") if __name__ == "__main__":