+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
Scripts Thread, Script to Delete Files and folders within a folder in Coding and Web Development; Lol, guess Steve beat me too! Damn me for testing first!...
  1. #16
    AlexB's Avatar
    Join Date
    Jul 2006
    Location
    Warwickshire
    Posts
    373
    Thank Post
    37
    Thanked 39 Times in 35 Posts
    Rep Power
    23
    Lol, guess Steve beat me too! Damn me for testing first!

  2. #17
    doddsworthy's Avatar
    Join Date
    Jul 2009
    Location
    Washington
    Posts
    18
    Thank Post
    3
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Thanks for those posts guys the script that "srochford" "Steve21" and "AlexB" worked a treat thanks very much for those guys. been a great help

  3. #18
    Zoom7000's Avatar
    Join Date
    Feb 2006
    Location
    London
    Posts
    958
    Thank Post
    309
    Thanked 86 Times in 57 Posts
    Rep Power
    33
    Quote Originally Posted by AlexB View Post
    If you want this just as a batch script then you could use

    Code:
    @echo off
    
    for /f "delims=" %%j in ( ' dir /b /ad' ) do del /f /s /q %%j
    
    for /f "delims=" %%j in ( ' dir /b /ad' ) do for /f "delims=" %%i in ( ' dir %%j /b /ad' ) do rd /s /q "%%j\%%i"
    This will first delete all files in all sub directories and then it deletes all sub folders too (I couldn't find a command to do both at the same time)

    so if you had for example a folder structure:-

    D
    --users
    ----y2010
    ------pupil1
    ------pupil2
    ----y2009
    ------pupil3
    ------pupil4
    ----y2008
    ------pupil5
    ------pupil6

    If you ran the batch file from inside each of the y2010, y2009 and y2008 folders then it would go into each sub folder (e.g. pupil1, 2, etc...) and empty both files and folders while leaving the pupil1, pupil2 folders in place.

    Obviously you need to be very careful with a batch file like this... running it in the wrong place could be bad
    Thanks for this! Worked exactly as I wanted it to!

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 5
    Last Post: 1st July 2014, 08:34 AM
  2. Script to delete certain folders
    By Pumaedition in forum Scripts
    Replies: 4
    Last Post: 22nd April 2008, 10:08 PM
  3. Replies: 2
    Last Post: 17th April 2008, 11:25 AM
  4. Replies: 5
    Last Post: 9th March 2008, 12:15 AM
  5. Replies: 3
    Last Post: 25th September 2006, 12:27 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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