A comprehensive CiviCRM extension that analyzes file uploads, identifies abandoned files, and provides efficient storage management tools.
(/civicrm/admin/setting/fileanalyzer)
The File Analyzer extension helps CiviCRM administrators monitor and manage file uploads by:
- Automatically scanning the custom file upload directory
- Identifying abandoned files (files not referenced in the database)
- Providing detailed analytics and visualizations
- Offering automated cleanup capabilities with backup options
- Storing scan results in JSON format for optimal performance
- Scans all files in the CiviCRM custom upload directory recursively
- Identifies files referenced vs. abandoned files
- Analyzes file types, sizes, and modification dates
- Generates monthly statistics and trends
- Interactive charts showing file type distribution
- Monthly file creation trends
- Top abandoned files by size
- Storage utilization statistics
- Scan history tracking
- Configurable auto-deletion of abandoned files
- Backup files before deletion option
- Customizable retention periods
- Safe deletion with database verification
- JSON-based caching system for fast dashboard loading
- Scheduled scanning prevents real-time performance impact
- Efficient database queries for file usage detection
CRM_Fileanalyzer_API_FileAnalysis::scheduledScan()
β
1. Scan custom file upload directory recursively
2. Check each file against database references
3. Generate comprehensive analysis data
4. Store results in JSON files:
- latest_scan_results.json (complete scan data)
- abandoned_files.json (abandoned files only)
- scan_results_[timestamp].json (historical data)
5. Perform auto-deletion if configured
CRM_Fileanalyzer_Page_Dashboard::run()
β
1. Read stored JSON files
2. Check if scan data exists
3. If no data: Prompt to run scheduled job
4. If data exists: Process and display analytics
5. Generate charts and statistics
-
Download the extension:
cd /path/to/civicrm/extensions git clone https://github.com/skvare/com.skvare.fileanalyzer.git -
Install via CiviCRM:
- Navigate to Administer β System Settings β Extensions
- Find "File Analyzer" and click Install
- Set up scheduled job:
- Go to Administer β System Settings β Scheduled Jobs
- Create a new job with API Entity:
FileAnalyzerand API Action:scheduledScan - Set frequency (recommended: daily)
Access via Administer β File Analyzer β Settings:
- Scan Interval: How often to run the scheduled scan (hours)
- Auto Delete: Enable automatic deletion of abandoned files
- Auto Delete Days: Files older than X days will be deleted
- Backup Before Delete: Create backup copies before deletion
- Excluded Extensions: File types to skip during scanning (comma-separated)
Auto Delete: Disabled (initially)
Auto Delete Days: 30 days
Backup Before Delete: Enabled
Excluded Extensions: .htaccess,.gitignore
Navigate to Administer β System Settings β File Analyzer
- Total files and storage usage
- Abandoned files count and size
- Last scan date and active files count
- File Types Distribution: Shows total vs abandoned files by extension
- Monthly Trends: File creation patterns over time
- Top Abandoned Files: Largest abandoned files for cleanup priority
- View detailed abandoned file listings
- Manual scan trigger for administrators
- Access to scan history and reports
Located in [customFileUploadDir]/file_analyzer_backups/:
file_analyzer_backups/
βββ latest_scan_results.json # Most recent complete scan
βββ abandoned_files.json # Current abandoned files
βββ scan_results_[timestamp].json # Historical scans
βββ deleted_files/ # Backup of deleted files
βββ reports/ # Generated reports
βββ .htaccess # Security protection
The extension checks multiple sources to determine if a file is in use:
- civicrm_file table: Direct file attachments
- Custom field tables: File-type custom fields
- civicrm_entity_file: Activity and entity attachments
- Backup directory protected with
.htaccess - JSON files contain paths but no sensitive content
- Only administrators can access the dashboard
- Deleted files are backed up before removal
- CiviCRM Administer: View dashboard and reports
- CiviCRM Administer: Configure settings and trigger scans
Problem: Dashboard shows "No files found, ask to run scheduled job" Solution:
- Check if scheduled job is configured and running
- Manually trigger scan via API or dashboard
- Verify custom file upload directory permissions
Problem: Scan job fails with errors Solution:
- Check CiviCRM log files for detailed errors
- Verify file system permissions on upload directory
- Ensure backup directory is writable
- Check PHP memory limits for large directories
Problem: Dashboard loads slowly Solution:
- Ensure using JSON-cached data, not live scanning
- Increase PHP memory limit if needed
- Consider excluding large file types from scanning
This extension is licensed under AGPL-3.0.
- Issues: Report bugs and feature requests on GitHub Issues
- Documentation: CiviCRM Extension Documentation
- Community: CiviCRM Stack Exchange
Skvare LLC specializes in CiviCRM development, Drupal integration, and providing technology solutions for nonprofit organizations, professional societies, membership-driven associations, and small businesses. We are committed to developing open source software that empowers our clients and the wider CiviCRM community.
Contact Information:
- Website: https://skvare.com
- Email: info@skvare.com
- GitHub: https://github.com/Skvare
You might also be interested in other Skvare CiviCRM extensions:
- Database Custom Field Check: Prevents adding custom fields when table limits are reached
- Image Resize: Resize images uploaded to CiviCRM with different dimensions
- Registration Button Label: Customize button labels on event registration pages
For a complete list of our open source contributions, visit our GitHub organization page.


