Please explain whether you want to “delete all directories except four new ones” or “delete all (files and directories), except for the four newest directories”.
Also note that the creation time is unknown for directories. You can only indicate when the directory was last modified, that is, files were added, deleted or renamed.
source share