Added empty folder deletion
This commit is contained in:
parent
022ca14a00
commit
7d684dec51
@ -13,3 +13,5 @@ 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.
|
||||||
|
9
sizer.py
9
sizer.py
@ -18,6 +18,13 @@ def pics_list(path:os.path):
|
|||||||
def file_move(file, dest):
|
def file_move(file, dest):
|
||||||
shutil.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():
|
def main():
|
||||||
#------------------ CONFIG START
|
#------------------ CONFIG START
|
||||||
@ -100,6 +107,8 @@ def main():
|
|||||||
dest_folder = foldersd
|
dest_folder = foldersd
|
||||||
print(f"{f} moved to {rootdir}{dest_folder}")
|
print(f"{f} moved to {rootdir}{dest_folder}")
|
||||||
|
|
||||||
|
delete_empty_folders(rootdir)
|
||||||
|
|
||||||
print("Done, Sayonara")
|
print("Done, Sayonara")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user