DelAll delete files and folders
-4
Deletes all files and folders from a directory, including read-only and
hidden files and folders. DelAll starts in the directory you tell it,
removes all read-only and hidden attributes from all the files, removes
all of the subfolders and then all files therein. When DelAll is done,
you will be left in the directory from which you called DelAll. The
directory that you want cleaned will not be deleted.
hidden files and folders. DelAll starts in the directory you tell it,
removes all read-only and hidden attributes from all the files, removes
all of the subfolders and then all files therein. When DelAll is done,
you will be left in the directory from which you called DelAll. The
directory that you want cleaned will not be deleted.
@Echo off
goto :MAIN
:DeleteAll
pushd %1
attrib -r -h *.* > nul
for /f "tokens=*" %%i in ('dir /b/ad') do rd /s/q "%%i"
del *.* /q
popd %1
goto :eof
:USAGE
echo Deletes ALL files and folders under the directory entered.
echo.
echo DelAll ^[drive:^]directory ^[/Y^]
echo.
echo ^[drive:^]directory
echo Directory to be cleaned. This directory will _not_ be deleted.
echo.
echo ^/Y Turns off confirmation before deleting.
echo.
echo DelAll is a potentially destructive utility. Use with caution!
goto :eof
:MAIN
if {%1}=={} (goto :USAGE) else if not exist "%~f1\." (goto :USAGE) else if
{%2}=={/y} (goto :DeleteAll %~f1)
echo Are you sure you want to delete all the files and folders in directory
choice "%~f1"
if %ERRORLEVEL%==1 goto :DeleteAll "%~f1"
echo Aborted.






There are currently no comments for this snippet.