I have a requirement to archive the aged files inside a huge upload folder which is causing the limit of allowed files count on the shared hosting platform even though hosting plan supports unlimited storage. So the hosting service is alerting because of huge file count as well as client want to minimize it.
My suggestion is,
1. Modify the application to archive or delete the aged files in a period over it.
2. Move the files our and compress it to another folder.
But client wants a immediate action and I go with script option. Basic idea is we need to create a file with custom creation date and use find command to list out the files between the period, use “exec” command to move it out to another folder. Then compress it.
1. I want to list out the files in between Oct 2010 and March 2011. So I want to create both files with specified creation date. Check the syntax yyymmddhhmmss
$touch -m -t 201103010000 /tmp/enddate
2. Use find command to list the files and no. counts
$find ~/public_html/uploads/photo_images -newer /tmp/startdate ! -newer /tmp/enddate |wc -l
3. Now I want to take a backup of moving files as a precaution. (Optional)
4. Compressing the backup files to minimise the file count
4. Finally deleting the unwanted files between the dates