DOS - Empty a Directory

Sure there is. Pick a programming/scripting language, give it 5 minutes and there you have it. If you want to take this road but feel awkward with programming, get AutoIt. I always recommend it to anyone who needs to script anything from opening notepad to macroing actions in a game.. hell, I even made a lightweight hunting bot on it once.

Lol, AutoIt is really, REALLY easy to use, made a MU bot ages ago with it! :p
 
Well since people still have no solution I took some time to write a script just for the fun of it, but still it beats me why you would need such a script in the first place.

Have fun! and perhaps good luck (with figuring out what it does).

Please bear in mind that this script can cause a lot of grief if your files on desktop exceed the xcopy's maximum 5000 files since not everything will be copied then but it WILL be deleted.

Code:
cls
@echo off

REM Step 0 - Determine desktop folder
echo Locating desktop folder
if exist "%userprofile%\desktop\*.*" goto EN
if exist "%userprofile%\bureaublad\*.*" goto NL
goto Unknown

:Unknown
REM !! SET DESKTOP FOLDER NAME BELOW HERE !! (only if not english or dutch windows) 
REM e.g desktopname=mydesk
set desktopname=Desktop
goto 1

:NL
set desktopname=Bureaublad
goto 2

:EN
set desktopname=Desktop
goto 2

:1
REM Step 1
echo Verifying desktop folder
if exist "%userprofile%\%desktopname%\*.*" goto 2
echo Desktop folder is incorrect
echo Please set correct folder in batch file
goto fout

:2
REM Step 2
if exist c:\unsorted\*.* goto 3
echo Creating folder "Unsorted" on C:\
md c:\unsorted>nul

:3
REM Step 3
echo Copying files from %desktopname% to other folder
xcopy "%userprofile%\%desktopname%\*.*" c:\unsorted\ /S /C /H /Y>nul
xcopy "%allusersprofile%\%desktopname%\*.*" c:\unsorted\ /S /C /H /Y>nul

REM Step 4
echo Removing files from %desktopname%
RMDIR "%userprofile%\%desktopname%" /S /Q
RMDIR "%allusersprofile%\%desktopname%" /S /Q

REM Step 5
echo Restoring default %desktopname% folder
MD "%userprofile%\%desktopname%"
MD "%allusersprofile%\%desktopname%"

echo All Done!
goto end

:fout
echo !! Error Occured !!
echo.
pause

:end
 
That hasn't worked for ages, same as Frag

Please read all post or none. 1 Post later, just right under the one you replied on FragFrog said and I quote:

And obviously you don't scan your links very well, or you'd know that deltree hasn't been included in windows for the past 9 years :wink:

just do the del foldername /S it should work, if not manually isn't the way for you :O

As for the solution, I already posted one. Well tested and proved to be working.
 
Back