Answers.Body: <p>Might justify developing a script or extension?</p>
  
  <ul>
  <li>The column <code>uri</code> in the database table <code>civicrm_file</code> seems to refer to these.
  
  <ul>
  <li>The table <code>civicrm_entity_file</code> then links <code>civicrm_file</code> records to other existing entities.</li>
  </ul></li>
  <li>The column <code>image_URL</code> in the table <code>civicrm_contact</code>, on my transplanted legacy installation at least:
  
  <ul>
  <li>in some cases contains absolute URLs that also reference files in this folder,</li>
  <li>and in others contains URLs to <code>civicrm/contact/imagefile</code> with a <code>photo</code> parameter that is a filename in this folder.</li>
  </ul></li>
  </ul>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-30T22:51:45.093Z
Answers.Text: Thanks for the breakdown of where the files may be referenced from. Seems like I have a fair bit of manual work to clean up this folder. Would be nice to figure out how to manage this folder - I'm sure that means writing an extension and I'm not sure I'd know where begin but I'll keep some notes on what might be helpful.
Answers.UserDisplayName: RayWright
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-12-17T08:54:13.797Z
Answers.Text: Note that files, which are uploaded in a text field with a wysiwyg editor, are not listed in the mentioned tables. Only their uri is saved as part of the html of this text field. So it's not that easy to find all usage.
Answers.UserDisplayName: Philipp Michael
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-21T09:39:41.163Z
Answers.LastActivityDate: 2018-03-21T09:39:41.163Z
Answers.UserDisplayName: DaveFF
Body: <p>I'm wondering if anyone else has come up with a good way to manage their custom files (where documents and images which are attachments to contact records are stored.) </p>
  
  <p>We have a fair amount of files in this folder. In addition, some of the contact images have been 'deleted' in Civi (i.e. mistakenly uploaded and replaced with a new image or updated with a newer image.)</p>
  
  <p>Any way to cull through the files and remove files no longer in use?
  Or to separate contact record images from pdfs attached to activity records?</p>
  
Tags: <directory><files><upload>
Title: Cleaning up images (or other files) in the custom folder
ThreadText: # Cleaning up images (or other files) in the custom folder
  
  (Asked by: username_0 on 2018-03-14)
  
  I'm wondering if anyone else has come up with a good way to manage their custom files (where documents and images which are attachments to contact records are stored.)
  
  We have a fair amount of files in this folder. In addition, some of the contact images have been 'deleted' in Civi (i.e. mistakenly uploaded and replaced with a new image or updated with a newer image.)
  
  Any way to cull through the files and remove files no longer in use?
  Or to separate contact record images from pdfs attached to activity records?
  
  **Tags:** directory, files, upload
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-03-21. Score: 2
  
  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.
  
  > **Comments:**
  > **username_0**: Thanks for the breakdown of where the files may be referenced from. Seems like I have a fair bit of manual work to clean up this folder. Would be nice to figure out how to manage this folder - I'm sure that means writing an extension and I'm not sure I'd know where begin but I'll keep some notes on what might be helpful.  
  > **username_2**: Note that files, which are uploaded in a text field with a wysiwyg editor, are not listed in the mentioned tables. Only their uri is saved as part of the html of this text field. So it's not that easy to find all usage.  
  
  ---
  
  