Delete all files that match date '+%Y-%m-%d_%H:%M'

I need to modify this so it delete all date files and not leave the 2 newest.

TARGET_DIR='/media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/'
REGEX='[0-9]{4}-[0-9]{2}-[0-9]{2}_[0-9]{2}:[0-9]{2}'   # regular expression that match to: date '+%Y-%m-%d_%H:%M'
LATEST_FILE="$(ls "$TARGET_DIR" | egrep "^${REGEX}$" | tail -1)"
find "$TARGET_DIR" ! -name "$LATEST_FILE" -type f -regextype egrep -regex ".*/${REGEX}$" -exec rm -f {} +
rsync --progress -r -u /media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/* /home/andy/Ubuntu_18.04_Programs/

And (with well over 100 posts in this forum so far) what have you tried to solve this problem on your own?

I showed my work. I am stuck.

I see no need to remind me how many posts I have made each time I post.

Well before the time you get to 100 posts, we expect you to have a basic understanding of the commands that you are posting and have some idea of what they are doing. Your question seems to imply that you have no idea what the code you have shown us is doing.

In post #1 you implied that the code you are using is keeping two "date" files. With the tail -1 I don't see anything in your code that would keep more than one file.

We would expect by now that you would know that the rm in the find -exec primary is what is being used to remove files and that the find ! -name "$LATEST_FILE" is what is keeping one file from being removed, and if that is the case it would seem that removing that primary from the find command would make that command also remove the file that is being skipped:

find "$TARGET_DIR" ! -type f -regextype egrep -regex ".*/${REGEX}$" -exec rm -f {} +

But, of course, I would never try that without first running:

find "$TARGET_DIR" ! -type f -regextype egrep -regex ".*/${REGEX}$" -exec echo rm -f {} +

and verifying that the rm commands that find prints are what you would expect them to be for what you are trying to do.

And, I don't see how the rsync command you have shown us has anything to do with the problem you have described.

Or, maybe I have misunderstood your problem. Are you saying that you want files removed from the target directory used in your rsync command instead of from the source directory used in your rsync command? But, if that was the case, we would expect you to say that none of the "date" files are being removed from that directory instead of implying that after you run this script only two "date" files are kept in that directory.

On giving it some more thought, I made a mistake in my post.

This is what created the date files. So by removing that command from my script, the date files are no longer created.

touch /media/andy/MAXTOR_SDB1/Ubuntu_Mate_18.04/$( date '+%Y-%m-%d_%H:%M' )