How to solve “The directory is not empty” error when running rmdir command in a batch script?

前端 未结 13 2240
悲&欢浪女
悲&欢浪女 2021-01-30 02:16

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

13条回答
  •  鱼传尺愫
    2021-01-30 02:52

    I'm familiar with this problem. The simplest workaround is to conditionally repeat the operation. I've never seen it fail twice in a row - unless there actually is an open file or a permissions issue, obviously!

    rd /s /q c:\deleteme
    if exist c:\deleteme rd /s /q c:\deleteme
    

提交回复
热议问题