Search code examples
cmddelrmdir

how to delete a directory in cmd, without deleting its content?


Im new to cmd, and I was given a task to delete a directory, without deleting its content, in one line. How can I do that? I had already tried rmdir and del, but they remove the content of the directory along with it. I thought about using move first in order to move the content, but I have no idea as for how to do it along with deleting the folder in one line. Any help would be much appreciated


Solution

  • Like this on all Microsoft OSes since 2000, and still good today:

    dir & echo foo
    

    If you want the second command to execute only if the first exited successfully:

    dir && echo foo
    

    As answered here.

    So you can easily move, then delete the folder all in one line.