Efficiently delete large directory containing too much of files

1. Rsync

Be sure to have backups of your files just in case.
When logged into your Retain Server, first you will need to create a new directory in any location of your choice.

mkdir empty_dir

Next, you will run this command.  empty_dir is the new directory you just created and yourdirectory is the directory you wish to remove:

rsync --progress -a --delete empty_dir/ yourdirectory/

rsync -a --delete empty_dir/ yourdirectory/

Once this command completes, both the new directory you created and the directory you wish to have deleted will still exist but all content inside them will be gone.  you can then manually remove those directories using the rm command.

2. Perl

cd yourdirectory/

perl -e 'for(<*>){((stat)[500000]<(unlink))}'

Check: limit the number of files printed by ls: ls -U | head -10