Last active
December 6, 2020 20:06
-
-
Save thehesiod/c2ac231d3f3bac5a9824de9d3efedffe to your computer and use it in GitHub Desktop.
Delete Empty Android DCIM folders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requires webdav connection (see WebDAV Server app, and ensure port is not 8080) | |
from pathlib import Path | |
import shutil | |
def main(): | |
cam_path = Path('//192.168.1.186@8081/DavWWWRoot/DCIM/Camera') | |
for idx, item in enumerate(cam_path.iterdir()): | |
if idx % 100 == 0: | |
print(f"Processing folder {idx}") | |
if not item.is_dir(): | |
continue | |
try: | |
if not ({i.name for i in item.glob('*')} - {'.deletemarkers'}): | |
print(f'deleting {item}') | |
shutil.rmtree(item) | |
except BaseException as e: | |
print(f"Skipping {item} due to {e}") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment