Delete empty subfolders, keep parent folder

Simply do find /home/user/parentdir -mindepth 1 -type d -empty -delete.

Look:

$ mkdir -p test1/test2
$ find test1 -type d
test1
test1/test2
$ find test1 -mindepth 1  -type d
test1/test2

The find /home/user/parentdir/* in AmourK’s answer is undesirable when there are a lot of files and it is overcomplicated.


By adding /* to the end of parentdir, you are performing the action on all subdirs of parentdir rather than on parentdir itself. And so in the same way /home/user/ is not deleted in the old command, parentdir will not be not be deleted in the command below. * is called a glob operator and it matches any string of characters.

find /home/user/parentdir/* -type d -empty -delete