I am making a batch script and part of the script is trying to remove a directory and all of its sub-directories. I am getting an intermittent error about a sub-directory not be
Similar to Harry Johnston's answer, I loop until it works.
set dirPath=C:\temp\mytest :removedir if exist "%dirPath%" ( rd /s /q "%dirPath%" goto removedir )