To remove old WhatsApp media from an Android phone connected by USB cable (with developer options enabled).
Use BetterAdbSync:
pip install BetterADBSync
Then run the following to back up to a folder in your home directory:
adbsync —show-progress pull sdcard/Android/media/com.whatsapp/WhatsApp/Media/ ~/Documents/WhatsApp\ Media/
Afterwards use adb shell
then run the following in the shell on your Android to delete media files older than 180 days:
find sdcard/Android/media/com.whatsapp/WhatsApp/Media/WhatsApp\ Images/ -type f -mtime +180 -delete
find sdcard/Android/media/com.whatsapp/WhatsApp/Media/WhatsApp\ Video/ -type f -mtime +180 -delete
find sdcard/Android/media/com.whatsapp/WhatsApp/Media/WhatsApp\ Documents/ -type f -mtime +180 -delete
exit
Modify -mtime +180
to change the age of the deleted files in days.