Delete an empty folder

Hello,
I would like to know if we can know the size of a directory, to detect if it is empty. My goal is to delete it.

Something like:

cleanup_dir_zz:
    filesystem:
      path: F:\zzJDL
      recursive: yes
      retrieve: dirs
     if:
       - size == 0: accept
    delete:
      allow_dir: yes
      clean_source: 2 

It could be “size” or “size_content”. Actually, there is “size_content” only for files.
thank you in advance !

you can use exec as output

Linux

filesystem:
  path: folder
  recursive: yes
  retrieve: dirs
accept_all: yes
exec: find {{path}} -type d -empty -delete

Windows

filesystem:
  path: folder
  recursive: yes
  retrieve: dirs
accept_all: yes
exec: rd /q {{path}} > nul

rd will fail on non-empty folders

thanks @epsiblivion for this solution.
I will have learned something useful.

I have meanwhile made a small plugin that does the trick.

Maybe it should be integrated with the plugin “filesystem”. Maybe one day… a PR…