0

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

Erel
  • 67
  • 8
  • Why one line? You can't delete the directory without moving the files and I can't think of a tool that handles it as a single command. – shawnt00 Aug 16 '20 at 14:09
  • that was the task i was given, i don't know why. im just trying to solve it – Erel Aug 16 '20 at 14:11
  • Did whomever tasked you, also send you for a long stand, and a glass hammer? If you have a container of objects, you cannot put that container in the garbage can, whilst keeping those objects, unless you move those contents somewhere else before disposal. So please expalain where you'd like us to move your contents before throwing out its container. This site also does not provide a code writing service. To learn how to use each command, you just need to read the built-in help information, `move /?`, `rd /?`, etc. – Compo Aug 16 '20 at 15:14

1 Answers1

0

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.

Merritt
  • 365
  • 5
  • 9
  • If this solves your question please mark as solved for future users reference :) – Merritt Aug 16 '20 at 15:23
  • 1
    @Erel, please do not mark this answer as the solution to your question, because it is not. This shows you two methods of combining one or more commands as a single line, it does not move contents or delete/remove objects. It is therefore an incomplete answer, technically it assists you with only a portion of what your question asks. If you only wanted to know how to combine multiple commands onto a single line, then you should upvote the linked answer, and delete your question, or edit your question accordingl, and it will be closed as a duplicate of that linked above. – Compo Aug 16 '20 at 16:00