Skip to content
⌘ NSIS Forum Archive

Only delete dir, if empty

2 posts

Guest#

Only delete dir, if empty

What is the best way to check, whether a directory and all its subdirectories are empty in order to delete the directory?

Image, you install an application. The uninstaller should only delete the directory, into which the application was installed, if the user never saved userdefined files in the application directory.
Afrow UK#
Just RMDir "dirpath" on every upper level directory down to the lowest level directory.
Without the /r switch, RMDir will not delete the folder unless it is empty.

-Stu