1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Rep Power

    Emptying a folder, not delete it.

    Im trying to get a script running.
    It should be able to delete all folders and files in a dir, Not delete the root folder.

    Ive searched for a script like this, but come up empty, exept for this.. ive modifyed it slightly..

    dir /b /ad c:\test > dirlist.txt
    for /f %%i in (dirlist.txt) do rd /s /q c:\test\%%i
    del c:\test\*.*

    This does the job, exept if a folder has "space" in it
    "c:\test\New Folder"
    it can not delete that folder.

    In the end the script would act as follows,
    COPY all Folders and Files
    FROM "%USERPROFILE%"\Desktop
    TO c:\Death
    DELETE all folders and Files from "Desktop"(Not deleting Desktop)

    After that i will manually go through "Death" and keep what is worth keeping.

    Please help.
  2. #2
  3. Moderator Emeritus
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Austin, TX
    Rep Power
    What programming language are you writing this in?
    DrGroove, Devshed Moderator | New to Devshed? Read the User Guide | Connect with me on LinkedIn
    The Most Important Article You Can Read as a Developer

IMN logo majestic logo threadwatch logo seochat tools logo