Mass-deleting the duplicates found by Nextcloud’s MediaDC

MediaDC, the duplicate collector app of Nextcloud, finds duplicate pictures well, but deleting thousands of them one by one in its interface is not an option.

mediadc-massdelete takes the JSON export of a MediaDC task and deletes the duplicates through WebDAV. When duplicates have a similar size, --include and --exclude choose which copy to delete based on its path. --different-path-only only deletes files in a different path, to avoid deleting pictures that are just a bit similar, and --dry-run shows what would be deleted without deleting anything.

Export the results of a MediaDC task as JSON (the README shows where), then run, for instance:

python3 mediadc_delete.py --exclude workspace --include DCIM Temp Import Upload temp \
  --host "https://server.com/nextcloud/remote.php/dav/files/user" \
  --login user --password XXX export.json --different-path-only

This prefers deleting the copies in DCIM, Temp, Import or Upload folders, and avoids deleting the ones under workspace.

▶️ Code