Reopen voters: The 'already answered' question, is different. I am not looking to match the folder names, I want to look at the creation date time and use this to find the x days. I will be looking for folders older than 6 months, so unless I am mistaken, the 'already answered' is incorrect.
Inside a directory, I store date named folders of website backups.
/Users/myname/Desktop/rsync/
As an example:
/Users/myname/Desktop/rsync/10-06-18
/Users/myname/Desktop/rsync/11-06-18
/Users/myname/Desktop/rsync/12-06-18
In my bash script, I need to check to find any direct descendants of the 'rsync' folder that are older than x days and delete them.
Using the following, I am able to find files that are older than 2 days, but this is within the child folders as well.
find /Users/myname/Desktop/rsync -mtime +2 -print
If anyone can show me how I would limit this to just the direct descendant folder and potentially how to delete them, that would be much appreciated.
-maxdepth
and-mindepth
, which is what you want to use, along with-prune
.-maxdepth 1
to this, apart from taking my comment to the (currently only) answer there into account.