logo elektroda
logo elektroda
X
logo elektroda

- CMD Command Line: Delete All Files and Folders without Deleting Original Folder (del & RD)

badboy23 32958 8
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16237938
    badboy23
    Level 27  
    Hello, I need from the command line, delete all files and folders from the folder, leaving the folder untouched.
    I tried del and RD but it does not go too far.
  • ADVERTISEMENT
  • ADVERTISEMENT
  • #3 16238016
    badboy23
    Level 27  
    Kasek21 wrote:
    enter: del *. *


    I need to be in this directory?
    I also did: \ test *. * Although I was not physically in the directory.
  • ADVERTISEMENT
  • #5 16238029
    Kolobos
    IT specialist
    No, but you have to enter the correct commands ...

    Np: del e: \ test \ *. *



    Ps. Description of dos dos commands is generally available, maybe it is worth reading and understanding?
  • #6 16238368
    badboy23
    Level 27  
    That's basically a bad word, and I did not even write the post correctly. I've already corrected, instead of a directory I should use the folder expression. Excuse me.
  • ADVERTISEMENT
  • #7 16238379
    dt1
    Admin of Computers group
    Properly:

    rd /s e:\test


    This approach will delete all contents of the e: \ test (including subfolders) and the folder itself. Then you can create it again - will not this solution be better than deleting everything separately? Del will delete files, so each subfolder seems to have to be replaced with a name to be deleted.
  • #8 16238381
    yogi009
    Level 43  
    In the past, the deltree command functioned , I do not know if it is still valid.
  • #9 16238392
    badboy23
    Level 27  
    dt1 wrote:
    Properly:

    rd /s e:\test


    This approach will delete all contents of the e: \ test (including subfolders) and the folder itself. Then you can create it again - will not this solution be better than deleting everything separately? Del will delete files, so each subfolder seems to have to be replaced with a name to be deleted.


    I think you're right to use rd & md and after the case

    Deltree give it away from xp but I can be wrong.

Topic summary

The discussion revolves around using CMD command line to delete all files and folders within a specified directory while keeping the directory itself intact. Users suggest using the command "del *.*" to delete files, but clarify that the command must be executed within the target directory. Another user recommends using "rd /s e:test" to remove all contents, including subfolders, but this command also deletes the folder itself. The conversation touches on the historical "deltree" command, which is no longer available in modern systems, and suggests using "rd" followed by "md" to recreate the folder after deletion.
Summary generated by the language model.
ADVERTISEMENT