When I use
find /home/user/parentdir -type d -empty -delete
it looks recursively for empty subfolders inside
/home/user/parentdir and deletes them. But if
/home/user/parentdir is also empty, it deletes the
parentdir folder too, which is undesirable for me.
I want to keep this
rsync some files to backup or cloud. After processing, I need to delete the empty folders, but seems unproductive to recreate
parentdir every time.
Any suggestions to keep
parentdir? I thought about creating a
.nocopy file inside it and exclude it from
rsync, but looks like overkill. Is there a more elegant way?