I need a script which will purge (remove) old backups from two internal drives. Since I already have an automated backup setup (using Chronosync) I'm thinking I can just have it run this script whenever it does its backup.
The first drive contains Adobe Lightroom catalogs. There are two backup folders on this drive:
/Volumes/Cache HD/Family/Backups/
and
/Volumes/Cache HD/Projects/Backups/
Within these folders you'll find an endless number of backup folders named with the date, such as:
2015-05-02 2214
2015-05-03 2329
2015-05-04 0049
2015-05-04 0645
2015-05-05 1441
2015-05-05 2119
2015-05-07 1756
At any time I'd like to keep no more than say the 4 most recent backups.
The second drive (incidently the Time Machine drive, using its root for this) consists of a folder with numerous media files (images, videos, audio files etc.) which are copied to here whenever I import anything new to Adobe Lightroom or via Adobe Photo-downloader, in addition to its main drive. This is just to ensure I have a backup from my memory cards in case the main drive goes down in the process etc.
The imported files are either placed directly in the backup folder (/Volumes/Time Machine/Media backups/) or in a sub-folder of it named something like "Imported on 2 May 2015". The folder naming depends on how I configure it in Lightroom so this might change.
I figure it might be best to purge according to the file's date, regardless of being in a sub-folder or not, so let's say I want to purge any file which is older than 3 weeks old, and if a sub-folder is purged so that it's empty that folder should also be deleted.
Are there any ready made scripts around which would be adapted for this use?
The first drive contains Adobe Lightroom catalogs. There are two backup folders on this drive:
/Volumes/Cache HD/Family/Backups/
and
/Volumes/Cache HD/Projects/Backups/
Within these folders you'll find an endless number of backup folders named with the date, such as:
2015-05-02 2214
2015-05-03 2329
2015-05-04 0049
2015-05-04 0645
2015-05-05 1441
2015-05-05 2119
2015-05-07 1756
At any time I'd like to keep no more than say the 4 most recent backups.
The second drive (incidently the Time Machine drive, using its root for this) consists of a folder with numerous media files (images, videos, audio files etc.) which are copied to here whenever I import anything new to Adobe Lightroom or via Adobe Photo-downloader, in addition to its main drive. This is just to ensure I have a backup from my memory cards in case the main drive goes down in the process etc.
The imported files are either placed directly in the backup folder (/Volumes/Time Machine/Media backups/) or in a sub-folder of it named something like "Imported on 2 May 2015". The folder naming depends on how I configure it in Lightroom so this might change.
I figure it might be best to purge according to the file's date, regardless of being in a sub-folder or not, so let's say I want to purge any file which is older than 3 weeks old, and if a sub-folder is purged so that it's empty that folder should also be deleted.
Are there any ready made scripts around which would be adapted for this use?