Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Deleting subdirectories using a batch file

    I am trying to delete all the contents of a folder using a batch file that runs automatically from task scheduler
    But I cannot delete the folders within that folder

    I am using
    del c:test /q

  2. #2
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Deleting subdirectories using a batch file

    Assuming you are running Windows XP or near offer:

    RD /Q /S "directory path"
    followed by
    MD "directory path"

    Look at the help info from RD /? for the reasoning!

    Be <big>EVER SO CAREFUL</big> you have specified the directory path correctly...

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  3. #3
    3 Star Lounger
    Join Date
    Nov 2004
    Location
    Nottingham, Nottinghamshire, United Kingdom
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting subdirectories using a batch file

    Hi Paul

    Try

    <font face="Georgia">del c:test* /q/s</font face=georgia>

    Note that this method will only delete all the FILES in the sub-directories- all the folders themselves will remain (albeit empty). Wasn't sure if that was what you wanted or not.

    HTH
    <font color=448800><font face="Comic Sans MS"><big>Lyra J </font color=448800></font face=comic></big>
    <img src=/S/flags/UK.gif border=0 alt=UK width=30 height=18> Ducking the arrows in Robin Hood country <IMG SRC=http://www.wopr.com/w3tuserpics/Lyra_J_sig.gif ALT="No, Admins, no! I'm sorry, okay!" title="No, Admins, no! I'm sorry, okay!">

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting subdirectories using a batch file

    Depending on your version of Windows/DOS, you may be able to use the DELTREE command.
    The same caution that John emphasizes applies.

    Alan

  5. #5
    Star Lounger
    Join Date
    Apr 2002
    Location
    Sydney, New South Wales, Australia
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Deleting subdirectories using a batch file

    Thank you for your help <img src=/S/joy.gif border=0 alt=joy width=23 height=23>
    It was good to learn all three methods.
    Thanks also for the caution .. oh the problems this could get me into if I got it wrong. <img src=/S/frown.gif border=0 alt=frown width=15 height=15>
    Will use it sparingly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •