Archive: RmDir (Remove Directory) only if empty?


RmDir (Remove Directory) only if empty?
Is there a way to check and see if a directory is empty, and if so, delete it?

I'm guessing something with wild cards to check and see if *.* exists or something? Am I on the right track here, or is there a built-in macro for this?

I thought something like this may work:


IfFileExists DIRECTORY\*.*


But that jumps if the directory exists, even if it is empty.

a directory always has two special files, '.' and '..' even if its "empty"

just doing RMDir "c:\foo" will only delete the folder if its empty


Ah okay, I had been using the /r flag, so RMDir /r DIRECTORY will remove the directory even if it's not empty.

Thanks.