Cleaning up images (or other files) in the custom folder
Might justify developing a script or extension?


The column uri in the database table civicrm_file seems to refer to these.


The table civicrm_entity_file then links civicrm_file records to other existing entities.

The column image_URL in the table civicrm_contact, on my transplanted legacy installation at least:


in some cases contains absolute URLs that also reference files in this folder,
and in others contains URLs to civicrm/contact/imagefile with a photo parameter that is a filename in this folder.



So you may be able to identify unreferenced files that way, although I won't guarantee that files in that folder can't be referenced from elsewhere too.