I am trying to automate the process of backing up my development files weekly. I want to automatically back up the files, filter through all of the files, and delete the files that have not been modified within the last 7 days, but retain the folder structure. For example, I will have many files named index.js, so in order to know where they belong, I would like the folder structure to be maintained and the file to stay in it's proper folder if it has been modified within the last 7 days. My process so far has been to
- Copy the whole folder containing all development files
This works no problem. It copies all 29K files. The next step is to get all of the content inside of the folder and filter it down.
Get Specified Finder Items ( The folder that was just copied )
Get Folder Contents ( Repeat for each subfolder found )
Right off the bat, I have an issue. When Getting Folder Contents and checking Repeat For Each Subfolder Found around 8,000 files are missing. I can't seem to figure out what is causing this or how to fix this.
If I ignore this and continue on, my next step is to filter down the items. I want to remove the items not modified within the last 7 days and since I want to retain the folder structure I want to make sure the item is not a folder
- Filter Finder Items
is set to find files where the date last modified is not in the last 7 days ( this should grab all of the files that have not been modified recently )
Filter Finder Items
now I filter through those results and make sure to grab all of the same files but no folders
Move Finder Items To Trash
- lastly these items that have not been modified within the last 7 days and are not folders are moved to the trash.
So if I ignore the initial 8,000 files missing when Automator initially gets the folder's contents, and run this it does not work as intended. It does delete a lot of files, but a ton of files that have not been modified within the past 7 days are left, and I can not figure out why some files are being deleted and some are being left. I'm not sure if there is a flaw in my process or what I am missing here. Can someone point me in the correct direction for what I am trying to achieve?